南飓风 发表于 前天 00:37

[解决]Flutter打包Android是出现FAILURE: Build failed with an exception

1.问题出现

本日我更新完flutter以后发现Gradle 从7.3 升级到最低8.0,然后gradle-wrapper.properties 里面升级到8.3了,图片如下
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
# distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-all.zip
distributionUrl=https\://mirrors.cloud.tencent.com/gradle/gradle-8.3-all.zip
https://i-blog.csdnimg.cn/direct/1e2961c3c20f4cb6952f70c6e57431e6.png然后打包APK时出现一个问题,如下
Flutter assets will be downloaded from https://storage.flutter-io.cn. Make sure you trust this source!
Launching lib\main.dart on ASUS I003DD in debug mode...
Flutter assets will be downloaded from https://storage.flutter-io.cn. Make sure you trust this source!

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:checkDebugAarMetadata'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
   > Could not find androidx.lifecycle:lifecycle-common:2.7.0.
   Searched in the following locations:
       - https://maven.aliyun.com/nexus/content/repositories/google/androidx/lifecycle/lifecycle-common/2.7.0/lifecycle-common-2.7.0.pom
       - https://maven.aliyun.com/repository/jcenter/androidx/lifecycle/lifecycle-common/2.7.0/lifecycle-common-2.7.0.pom
       - https://maven.aliyun.com/repository/public/androidx/lifecycle/lifecycle-common/2.7.0/lifecycle-common-2.7.0.pom
       - https://storage.flutter-io.cn/download.flutter.io/androidx/lifecycle/lifecycle-common/2.7.0/lifecycle-common-2.7.0.pom
   Required by:
         project :app > io.flutter:flutter_embedding_debug:1.0.0-db49896cf25ceabc44096d5f088d86414e05a7aa
   > Could not find androidx.lifecycle:lifecycle-common-java8:2.7.0.
   Searched in the following locations: https://i-blog.csdnimg.cn/direct/5402df64c345406ba460c03e7af95e9b.png2.挖掘问题根源

我任意抓去一个链接访问看看,比如这个
 
https://maven.aliyun.com/nexus/content/repositories/google/androidx/lifecycle/lifecycle-common/2.7.0/lifecycle-common-2.7.0.pom 然后上阿里云的镜像网站搜刮这个工具 lifecycle-common
https://i-blog.csdnimg.cn/direct/36c341b6126740ac85aa60297b7ab12a.png
好家伙,阿里云还没更新2.7版本,最高2.6.1版本,所以我在build.gradle里屏蔽了阿里云,写了腾讯的
https://i-blog.csdnimg.cn/direct/e4b1186ff6364f738ff698e574906158.png
maven { url 'https://mirrors.tencent.com/nexus/repository/maven-public/' } // 腾讯云仓库
      mavenCentral() 3.解决问题

不出意外,这次乐成解决了
https://i-blog.csdnimg.cn/direct/739176ef80df41959bb68b85b71758f7.png
4.注意

gradle最小可以8.0开始,8.3换腾讯的源也下载很慢,耐心等待

免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
页: [1]
查看完整版本: [解决]Flutter打包Android是出现FAILURE: Build failed with an exception