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

打印 上一主题 下一主题

主题 876|帖子 876|积分 2628

1.问题出现

本日我更新完flutter以后发现Gradle 从7.3 升级到最低8.0,然后gradle-wrapper.properties 里面升级到8.3了,图片如下
  1. distributionBase=GRADLE_USER_HOME
  2. distributionPath=wrapper/dists
  3. zipStoreBase=GRADLE_USER_HOME
  4. zipStorePath=wrapper/dists
  5. # distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-all.zip
  6. distributionUrl=https\://mirrors.cloud.tencent.com/gradle/gradle-8.3-all.zip
复制代码

然后打包APK时出现一个问题,如下
  1. Flutter assets will be downloaded from https://storage.flutter-io.cn. Make sure you trust this source!
  2. Launching lib\main.dart on ASUS I003DD in debug mode...
  3. Flutter assets will be downloaded from https://storage.flutter-io.cn. Make sure you trust this source!
  4. FAILURE: Build failed with an exception.
  5. * What went wrong:
  6. Execution failed for task ':app:checkDebugAarMetadata'.
  7. > Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
  8.    > Could not find androidx.lifecycle:lifecycle-common:2.7.0.
  9.      Searched in the following locations:
  10.        - https://maven.aliyun.com/nexus/content/repositories/google/androidx/lifecycle/lifecycle-common/2.7.0/lifecycle-common-2.7.0.pom
  11.        - https://maven.aliyun.com/repository/jcenter/androidx/lifecycle/lifecycle-common/2.7.0/lifecycle-common-2.7.0.pom
  12.        - https://maven.aliyun.com/repository/public/androidx/lifecycle/lifecycle-common/2.7.0/lifecycle-common-2.7.0.pom
  13.        - https://storage.flutter-io.cn/download.flutter.io/androidx/lifecycle/lifecycle-common/2.7.0/lifecycle-common-2.7.0.pom
  14.      Required by:
  15.          project :app > io.flutter:flutter_embedding_debug:1.0.0-db49896cf25ceabc44096d5f088d86414e05a7aa
  16.    > Could not find androidx.lifecycle:lifecycle-common-java8:2.7.0.
  17.      Searched in the following locations:
复制代码
2.挖掘问题根源


我任意抓去一个链接访问看看,比如这个
 
  1. https://maven.aliyun.com/nexus/content/repositories/google/androidx/lifecycle/lifecycle-common/2.7.0/lifecycle-common-2.7.0.pom
复制代码
然后上阿里云的镜像网站搜刮这个工具 lifecycle-common

好家伙,阿里云还没更新2.7版本,最高2.6.1版本,所以我在build.gradle里屏蔽了阿里云,写了腾讯的

  1. maven { url 'https://mirrors.tencent.com/nexus/repository/maven-public/' } // 腾讯云仓库
  2.         mavenCentral()  
复制代码
3.解决问题

不出意外,这次乐成解决了

4.注意

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

免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
回复

使用道具 举报

0 个回复

倒序浏览

快速回复

您需要登录后才可以回帖 登录 or 立即注册

本版积分规则

南飓风

金牌会员
这个人很懒什么都没写!

标签云

快速回复 返回顶部 返回列表