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' }
}
...
相关推荐
fouryears_2341732 分钟前
现代 Android 后台应用读取剪贴板最佳实践
android·前端·flutter·dart
等你等了那么久1 小时前
Flutter国际化语言轻松搞定
flutter·dart
神经蛙39717 小时前
settings.gradle' line: 22 * What went wrong: Plugin [id: 'org.jetbrains.kotlin.a
flutter
stringwu8 小时前
一个bug 引发的Dart 与 Java WeakReference 对比探讨
flutter
火柴就是我1 天前
从头写一个自己的app
android·前端·flutter
●VON1 天前
Flutter 项目成功运行后,如何正确迁移到 OpenHarmony?常见疑问与跳转失效问题解析
flutter·华为·openharmony·开源鸿蒙
●VON1 天前
Flutter 编译开发 OpenHarmony 全流程实战教程(基于 GitCode 社区项目)
flutter·openharmony·gitcode
消失的旧时光-19432 天前
Flutter 组件:Row / Column
flutter
程序员老刘2 天前
Flutter版本选择指南:3.35稳定,3.38发布 | 2025年11月
flutter·客户端
kirk_wang2 天前
Flutter 3.38和Dart 3.10中最大的更新
flutter