修改项目中的android/build.gradle,将google(),mavenCentral()替换为下面的代码
maven { url 'https://maven.aliyun.com/repository/central/' } maven { url 'https://maven.aliyun.com/repository/public/' } maven { url 'https://maven.aliyun.com/repository/google/' } maven { url 'https://maven.aliyun.com/repository/gradle-plugin/' }
找到flutter的安装路径,找到packages\flutter_tools\gradle下的flutter.gradle文件,找到buildscript对象,对里面的repositories内容进行修改,换成以下代码
buildscript { repositories { maven { url 'https://maven.aliyun.com/repository/central/' } maven { url 'https://maven.aliyun.com/repository/public/' } maven { url 'https://maven.aliyun.com/repository/google/' } maven { url 'https://maven.aliyun.com/repository/gradle-plugin/' } dependencies { classpath 'com.android.tools.build:gradle:7.3.0' }}
依然在flutter.gradle文件中使用“ctrl+F”搜索DEFAULT_MAVEN_HOST,修改为以下代码
private static final String DEFAULT_MAVEN_HOST = "https://storage.flutter-io.cn";
(本文的flutter版本为Flutter 3.10.6)
参考:
flutter运行一直显示Running Gradle task 'assembleDebug'.
来源地址:https://blog.csdn.net/woai_mihoutao/article/details/131964365