Error running Gradle 错误
在Debug项目的时候, 出现 Error running Gradle:一般是因为不能翻墙的原因,
Launching lib\main.dart on FRD AL10 in debug mode...
Initializing gradle...
Resolving dependencies...
- Error running Gradle:
ProcessException: Process "E:\studyDemo\FlutterDome\flutter_app\android\gradlew.bat" exited abnormally:
Starting a Gradle Daemon (subsequent builds will be faster)
FAILURE: Build failed with an exception.
- What went wrong:
A problem occurred configuring root project 'android'.
Could not resolve all artifacts for configuration ':classpath'.
Could not download kotlin-compiler-embeddable.jar (org.jetbrains.kotlin:kotlin-compiler-embeddable:1.2.71)
Could not get resource 'https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-compiler-embeddable/1.2.71/kotlin-compiler-embeddable-1.2.71.jar'.
Read timed out
Could not download fastutil.jar (it.unimi.dsi:fastutil:7.2.0)
Could not get resource 'https://jcenter.bintray.com/it/unimi/dsi/fastutil/7.2.0/fastutil-7.2.0.jar'.
Read timed out
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 5m 32s
Command: E:\studyDemo\FlutterDome\flutter_app\android\gradlew.bat app:properties
Finished with error: Please review your Gradle project setup in the android/ folder.
解决方案是改位阿里的链接(1.0已经修复了这个问题,不用再重新设置了)。
第一步:修改掉项目下的android目录下的build.gradle文件,把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' }
第二步:修改Flutter SDK包下的flutter.gradle文件,这个目录要根据你的SDK存放的位置有所变化。比如我放在了D盘Flutter目录下,那路径就是这个。
D:\Flutter\flutter\packages\flutter_tools\gradle
打开文件进行修改,修改代码如下(其实也是换成阿里的路径就可以了)。
这一步有两种情况
1,flutter.gradle文件中repositories中是google() 和 jcenter(),
repositories{
google()
gcenter()
}
把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' }
2,flutter.gradle文件中repositories中是下图这样的,我们只用把repositories 中的代码注释掉
repositories {
jcenter()
maven {
url 'https://dl.google.com/dl/android/maven2'
}
换成
maven{
url 'https://maven.aliyun.com/repository/jcenter'
}
maven{
url 'http://maven.aliyun.com/nexus/content/groups/public'
}
最终就是这样的
repositories {
//jcenter()
// maven {
// url 'https://dl.google.com/dl/android/maven2'
// }
maven{
url 'https://maven.aliyun.com/repository/jcenter'
}
maven{
url 'http://maven.aliyun.com/nexus/content/groups/public'
}
}