Error running Gradle 錯誤
在Debug項目的時候茬末, 出現(xiàn) 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已經(jīng)修復了這個問題,不用再重新設(shè)置了)。
第一步:修改掉項目下的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文件,這個目錄要根據(jù)你的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'
}
}