flutter项目无法下载jcenter等包配置
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)
- 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
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'
}
}
然后再重新Debug一下,就基本可以启动起来。 【flutter项目无法下载jcenter等包配置】原文:https://blog.csdn.net/mo911108/article/details/88603003
推荐阅读
- 解决SpringBoot引用别的模块无法注入的问题
- 17|17 关山松 第二课作业#公众号项目# D20
- RxJava|RxJava 在Android项目中的使用(一)
- Android7.0|Android7.0 第三方应用无法访问私有库
- 无论你是谁,都有两件事,无法掌控
- Hacking|Hacking with iOS: SwiftUI Edition - SnowSeeker 项目(一)
- 靠QQ月入上万灰色暴利偏门的项目
- Flutter的ListView
- spring|spring boot项目启动websocket
- 没有思考时