Error running Gradle 錯(cuò)誤
在Debug項(xiàng)目的時(shí)候, 出現(xiàn) Error running Gradle:一般是因?yàn)椴荒芊瓑Φ脑颍?/p>
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已經(jīng)修復(fù)了這個(gè)問(wèn)題,不用再重新設(shè)置了)。
第一步:修改掉項(xiàng)目下的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文件,這個(gè)目錄要根據(jù)你的SDK存放的位置有所變化。比如我放在了D盤Flutter目錄下,那路徑就是這個(gè)。
D:\Flutter\flutter\packages\flutter_tools\gradle
打開(kāi)文件進(jìn)行修改,修改代碼如下(其實(shí)也是換成阿里的路徑就可以了)。
這一步有兩種情況
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'
}
}