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' }
}
...
相关推荐
yuanlaile7 小时前
纯Dart Flutter库适配HarmonyOS
flutter·华为·harmonyos·flutter开发鸿蒙·harmonyos教程
yuanlaile7 小时前
Flutter开发HarmonyOS 鸿蒙App的好处、能力以及把Flutter项目打包成鸿蒙应用
flutter·华为·harmonyos·flutter开发鸿蒙
zacksleo8 小时前
鸿蒙原生开发手记:04-一个完整元服务案例
flutter
jcLee951 天前
Flutter/Dart:使用日志模块Logger Easier
flutter·log4j·dart·logger
tmacfrank1 天前
Flutter 异步编程简述
flutter
tmacfrank1 天前
Flutter 基础知识总结
flutter
叫我菜菜就好1 天前
【Flutter_Web】Flutter编译Web第三篇(网络请求篇):dio如何改造方法,变成web之后数据如何处理
前端·网络·flutter
AiFlutter2 天前
Flutter-底部分享弹窗(showModalBottomSheet)
java·前端·flutter
m0_748247803 天前
Flutter Intl包使用指南:实现国际化和本地化
前端·javascript·flutter
迷雾漫步者3 天前
Flutter组件————PageView
flutter·跨平台·dart