Flutter新手第一个坑:Could not find com
搭建完环境,run起来,满怀期待,结果:
Launching 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.
真心凉,检查android 项目下gradle,没问题啊,该有的都有。
没办法,那就检查flutter sdk 吧,找到,fluttersdk/flutter/packages/flutter_tools/gradle/flutter.gradle,神奇的发现,buildscript {
repositories {
jcenter()
maven {
url 'https://dl.google.com/dl/android/maven2'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
}
}
缺少google(),把它加进去,完美解决。
我是有VPN的,没有VPN的就要想办法翻墙啦,但是强大的发改委会让你撞墙的。哈哈,用镜像吧,大兄弟。
第一步:修改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注释掉。
buildscript {
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'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
}
}
也可以解决掉问题。
最后我想说,大Google公司,你虽然没有发布realse版本,但是beta你也不用这么随意吧。。