一、Gradle 下载失败导致出错,timeout
- 找到grapple-wrapper.properties 在最下面的 distributionUrl 查看自己的 gradle 版本(我是 gradle-4.6-all.zip),复制链接的 URL,自行下载压缩包。
- 打开终端 输入 open ~/. gradle ,会自动进入 Finder,gradle 所在的目录。
- 将自行下载的压缩包复制到对应版本的文件夹下(以我的版本为例:我们下在的压缩包应该存放的目录为:~/.gradle/gradle-4.6/xxxxxxxxx/gradle-4.6-all,xxxxx 表示一堆乱七八糟的字符,最好先把原文件夹内的文件先删除),并解压缩。
- 再次执行编译,应该可以正常通过。
二、Error running Gradle,jar 文件下载失败
问题详情:
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
28Launching lib/main.dart on Android SDK built for x86 in debug mode...
Initializing gradle...
Resolving dependencies...
* Error running Gradle:
ProcessException: Process "/Users/rabbit/develop/android/flutter_app/android/gradlew" exited abnormally:
Project evaluation failed including an error in afterEvaluate {}. Run with --stacktrace for details of the afterEvaluate {} error.
FAILURE: Build failed with an exception.
* Where:
Build file '/Users/rabbit/develop/android/flutter_app/android/app/build.gradle' line: 25
* What went wrong:
A problem occurred evaluating project ':app'.
Could not resolve all files for configuration 'classpath'.
Could not find lint-gradle-api.jar (com.android.tools.lint:lint-gradle-api:26.1.2).
Searched in the following locations:
https://jcenter.bintray.com/com/android/tools/lint/lint-gradle-api/26.1.2/lint-gradle-api-26.1.2.jar
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 0s
Command: /Users/rabbit/develop/android/flutter_app/android/gradlew app:properties
Finished with error: Please review your Gradle project setup in the android/ folder.提示 .jar 文件下载失败。
解决方法:
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
38
39
40
41
42
43
44
45
46步骤1:修改build.gradle,注释掉jcenter(),google()。使用阿里的镜像。原因是 jcenter google 库无法访问到导致的问题。虽然我有万能的爬墙工具,开启全局代理依然被我们伟大的发改委墙掉了!
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.1.2'
}
}
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' }
}
}
第二步:找到 fluttersdk 目录 进入如下目录
Macintosh HD ▸ 用户 ▸ rabbit ▸ 资源库 ▸ Flutter ▸ packages ▸ flutter_tools ▸ gradle
找到下 flutter.gradle 文件 找如如下内容替换成和我一样的把 jcenter(),google() 注释掉。
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.1.2'
}
}
// 重新运行,解决掉问题。