Error running Gradle:
ProcessException: Process "D:\Android\APP path\flutter_app2\flutter_app2\android\gradlew.bat" exited abnormally:
> Configure project :app
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 'D:\Android\APP path\flutter_app2\flutter_app2\android\app\build.gradle' line: 25
* What went wrong:
A problem occurred evaluating project ':app'.
> Could not resolve all artifacts for configuration 'classpath'.
> Could not find com.android.tools.build:gradle:3.2.1.
Searched in the following locations:
- https://maven.aliyun.com/repository/jcenter/com/android/tools/build/gradle/3.2.1/gradle-3.2.1.pom
- https://maven.aliyun.com/repository/jcenter/com/android/tools/build/gradle/3.2.1/gradle-3.2.1.jar
- http://maven.aliyun.com/nexus/content/groups/public/com/android/tools/build/gradle/3.2.1/gradle-3.2.1.pom
- http://maven.aliyun.com/nexus/content/groups/public/com/android/tools/build/gradle/3.2.1/gradle-3.2.1.jar
Required by:
unspecified:unspecified:unspecified
* 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 3s
Picked up _JAVA_OPTIONS: -Djava.NET.preferIPv4Stack=true
Command: D:\Android\APP path\flutter_app2\flutter_app2\android\gradlew.bat app:properties
Please review your Gradle project setup in the android/ folder.
大致意思是说:运行Gradle时出错,导致构建flutter构建失败
原因是因为获取不到com.android.tools.build:gradle:3.2.1
原因一:
获取不到的原因一般是因为在中国没办法访问谷歌资源(有外网,翻墙等的除外)
此时的解决办法是 改用阿里的镜像:
分两步,
第一步:修改掉项目下的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存放位置,例如我的flutter.gradle
(C:\flutter\packages\flutter_tools\gradle)
同样将google() 和 jcenter()修改为阿里的链接
maven { url 'https://maven.aliyun.com/repository/jcenter' }
maven { url 'http://maven.aliyun.com/nexus/content/groups/public' }
至此,在国内没办法访问谷歌资源的问题就解决了
然而,我的问题并没解决
仔细看报错信息后,发现找不到以下资源地址
- https://maven.aliyun.com/repository/jcenter/com/android/tools/build/gradle/3.2.1/gradle-3.2.1.pom
- https://maven.aliyun.com/repository/jcenter/com/android/tools/build/gradle/3.2.1/gradle-3.2.1.jar
- http://maven.aliyun.com/nexus/content/groups/public/com/android/tools/build/gradle/3.2.1/gradle-3.2.1.pom
- http://maven.aliyun.com/nexus/content/groups/public/com/android/tools/build/gradle/3.2.1/gradle-3.2.1.jar
看到这里说明阿里链接是配置上了的,之所以找不到是因为gradle-3.2.1这个3.2.1版本太高了,应该是最新的
阿里连接中的gradle最高版本好像才3.1.2,所以获取不到
所以,解决办法是将项目下的android目录下的build.gradle
文件和flutter SDK包下的flutter.gradle
文件中的gradle版本改为阿里镜像中存在的版本