Android项目运行时出错
卡在Initializing gradle…
运行时会卡在Initializing gradle...
, 此时因为Android项目会用到Gradle
, 如果没有FQ,下载速度会非常慢, 此时我们可以在项目中的android/gradle/wrapper/gradle-wrapper.properties
中查看gradle
版本号以及地址, 我们可以手动下载然后解压到~/.gradle/wrapper/dists/
中。
卡在Running ‘gradle assembleDebug
运行时会卡在Running 'gradle assembleDebug
, 因为Gradle的Maven仓库在国外, 可以使用阿里云的镜像地址。
* 修改项目中`android/build.gradle`文件
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
|
buildscript { repositories { //修改的地方 //google() //jcenter() maven { url 'https://maven.aliyun.com/repository/google' } maven { url 'https://maven.aliyun.com/repository/jcenter' } maven { url 'http://maven.aliyun.com/nexus/content/groups/public' } }
dependencies { classpath 'com.android.tools.build:gradle:3.2.1' } }
allprojects { repositories { //修改的地方 //google() //jcenter() maven { url 'https://maven.aliyun.com/repository/google' } maven { url 'https://maven.aliyun.com/repository/jcenter' } maven { url 'http://maven.aliyun.com/nexus/content/groups/public' } } }
rootProject.buildDir = '../build' subprojects { project.buildDir = "${rootProject.buildDir}/${project.name}" } subprojects { project.evaluationDependsOn(':app') }
task clean(type: Delete) { delete rootProject.buildDir }
|
* 修改Flutter的配置文件, 该文件在`Flutter安装目录/packages/flutter_tools/gradle/flutter.gradle`
1 2 3 4 5 6 7 8 9 10 11 12 13
|
buildscript { repositories { //修改的地方 //google() //jcenter() maven { url 'https://maven.aliyun.com/repository/google' } maven { url 'https://maven.aliyun.com/repository/jcenter' } maven { url 'http://maven.aliyun.com/nexus/content/groups/public' } } dependencies { classpath 'com.android.tools.build:gradle:3.2.1' } }
|