Flutter编译一直显示Running Gradle task ‘assembleDebug‘

🔥 目前开发的Android Studio版本 🔥

🔥 当前Flutter SDK 版本 🔥

Dart 复制代码
Flutter 3.10.6 • channel stable • https://github.com/flutter/flutter.git
Framework • revision f468f3366c (3 周前) • 2023-07-12 15:19:05 -0700
Engine • revision cdbeda788a
Tools • Dart 3.0.6 • DevTools 2.23.1

🔥 修改Flutter项目下的android下的build.gradle 🔥

buildscript {
    ext.kotlin_version = '1.7.10'
    repositories {
        //google()
        //mavenCentral()
        maven { url 'https://maven.aliyun.com/repository/google' }
        maven { url 'https://maven.aliyun.com/repository/jcenter' }
        maven { url 'https://maven.aliyun.com/repository/public' }
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:7.4.1'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

allprojects {
    repositories {
        //google()
        //mavenCentral()
        maven { url 'https://maven.aliyun.com/repository/google' }
        maven { url 'https://maven.aliyun.com/repository/jcenter' }
        maven { url 'https://maven.aliyun.com/repository/public' }
    }
}
.....

🔥 修改Flutte SDK目录下的Flutter打包配置文件flutter.gradle 🔥

一般位于flutter\packages\flutter_tools\gradle\flutter.gradle

Dart 复制代码
buildscript {
    repositories {
        //google()
        //mavenCentral()
        maven { url 'https://maven.aliyun.com/repository/google' }
        maven { url 'https://maven.aliyun.com/repository/jcenter' }
        maven { url 'https://maven.aliyun.com/repository/public' }
    }
    dependencies {
        /** When bumping, also update ndkVersion above, as well as the Android Gradle Plugin
         * version in ../lib/src/android/gradle_utils.dart.
         */
        classpath 'com.android.tools.build:gradle:7.3.0'
    }
}
Dart 复制代码
    //此处可以配置环境变量FLUTTER_STORAGE_BASE_URL为 https://storage.flutter-io.cn来达到相同的效果
    private static final String DEFAULT_MAVEN_HOST = "https://storage.flutter-io.cn";
    //private static final String DEFAULT_MAVEN_HOST = "https://storage.googleapis.com";
Dart 复制代码
    @Override
    void apply(Project project) {
        .....
        // Configure the Maven repository.
        String hostedRepository = System.env.FLUTTER_STORAGE_BASE_URL ?: DEFAULT_MAVEN_HOST
        String repository = useLocalEngine()
            ? project.property('local-engine-repo')
            : "$hostedRepository/download.flutter.io"
        rootProject.allprojects {
            repositories {
                maven {
                    url repository
                }
                //追加下面的内容
                maven { url 'https://maven.aliyun.com/repository/google' }
                maven { url 'https://maven.aliyun.com/repository/jcenter' }
                maven { url 'https://maven.aliyun.com/repository/public' }
            }
        }
        .....
    }

🔥 修改Flutte SDK目录下的resolve_dependencies.gradle 🔥

一般位于flutter\packages\flutter_tools\gradle\resolve_dependencies.gradle

Dart 复制代码
...
//此处可以配置环境变量FLUTTER_STORAGE_BASE_URL为 https://storage.flutter-io.cn来达到相同的效果
String storageUrl = System.getenv('FLUTTER_STORAGE_BASE_URL') ?: "https://storage.flutter-io.cn"
//String storageUrl = System.getenv('FLUTTER_STORAGE_BASE_URL') ?: "https://storage.googleapis.com"

repositories {
    //google()
    //mavenCentral()
    maven {
        url "$storageUrl/download.flutter.io"
    }
    //追加下面
    maven { url 'https://maven.aliyun.com/repository/google' }
    maven { url 'https://maven.aliyun.com/repository/jcenter' }
    maven { url 'https://maven.aliyun.com/repository/public' }
}
...
相关推荐
君蓦11 小时前
Flutter 本地存储与数据库的使用和优化
flutter
problc20 小时前
Flutter中文字体设置指南:打造个性化的应用体验
android·javascript·flutter
lqj_本人1 天前
鸿蒙next选择 Flutter 开发跨平台应用的原因
flutter·华为·harmonyos
lqj_本人1 天前
Flutter&鸿蒙next 状态管理框架对比分析
flutter·华为·harmonyos
起司锅仔2 天前
Flutter启动流程(2)
flutter
hello world smile2 天前
最全的Flutter中pubspec.yaml及其yaml 语法的使用说明
android·前端·javascript·flutter·dart·yaml·pubspec.yaml
lqj_本人2 天前
Flutter 的 Widget 概述与常用 Widgets 与鸿蒙 Next 的对比
flutter·harmonyos
iFlyCai2 天前
极简实现酷炫动效:Flutter隐式动画指南第二篇之一些酷炫的隐式动画效果
flutter
lqj_本人2 天前
Flutter&鸿蒙next 中使用 MobX 进行状态管理
flutter·华为·harmonyos