1、翻墙
2、修改国内镜像源(以下以Flutter 3.19.3版本为例)
- 找到Flutter SDK目录下的Flutter配置文件resolve_dependencies.gradle
路径:flutter/packages/flutter_tools/gradle/resolve_dependencies.gradle
1)、第一处修改:
google()
mavenCentral()
改为:
maven { url 'https://maven.aliyun.com/repository/central' }
maven { url 'https://maven.aliyun.com/repository/gradle-plugin' }
maven { url 'https://maven.aliyun.com/repository/google' }
maven { url 'https://maven.aliyun.com/repository/public'}
2)、第二处修改:
url "storageUrl/{engineRealm}download.flutter.io"
改为:url "https://mirrors.tuna.tsinghua.edu.cn/flutter/download.flutter.io"
- 找到Flutter SDK目录下的Flutter配置文件flutter.groovy
地址为: flutter/packages/flutter_tools/gradle/src/main/groovy
1)、第一处修改
google()
mavenCentral()
改为:
maven { url 'https://maven.aliyun.com/repository/central' }
maven { url 'https://maven.aliyun.com/repository/gradle-plugin' }
maven { url 'https://maven.aliyun.com/repository/google' }
maven { url 'https://maven.aliyun.com/repository/public'}
2)、第二处修改
DEFAULT_MAVEN_HOST = "https://storage.googleapis.com";
改为:DEFAULT_MAVEN_HOST = "https://mirrors.tuna.tsinghua.edu.cn/flutter"
3.修改项目根目录下Android/build.gradle文件镜像地址
google()
mavenCentral()
改为:
maven { url 'https://maven.aliyun.com/repository/central' }
maven { url 'https://maven.aliyun.com/repository/gradle-plugin' }
maven { url 'https://maven.aliyun.com/repository/google' }
maven { url 'https://maven.aliyun.com/repository/public'}
4.修改项目gradle下载地址
路径:项目根目录/android/gradle/wrapper/gradle-wrapper.properties
改:
https\://services.gradle.org/distributions/gradle-xx.zip
为:
https://mirrors.cloud.tencent.com/gradle/gradle-xx.zip
over!