flutter解决Could not resolve all artifacts for configuration ‘:classpath’.

这篇博客主要讨论了在Android开发中遇到的Gradle构建失败的问题,特别是'assembleRelease'任务执行时,由于Jetifier在转换libs.jar时找不到文件导致的错误。作者提供了两种解决方案:一是将build.gradle中的google()和jcenter()替换为阿里云的maven源;二是尝试直接运行项目来解决问题。此外,博客还提醒读者如果问题依然存在,可以在Google Issue Tracker上报告错误。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >


FAILURE: Build failed with an exception.
 
* What went wrong:
Execution failed for task ':app:lintVitalRelease'.
> Could not resolve all artifacts for configuration ':app:debugRuntimeClasspath'.
   > Failed to transform libs.jar to match attributes {artifactType=processed-jar, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}.
      > Execution failed for JetifyTransform: /Users/aaaa/a-master/example/build/app/intermediates/flutter/debug/libs.jar.
         > Failed to transform '/Users/aaaa/a-master/example/build/app/intermediates/flutter/debug/libs.jar' using Jetifier. Reason: FileNotFoundException, message: /Users/aaaa/a-master/example/build/app/intermediates/flutter/debug/libs.jar (No such file or directory). (Run with --stacktrace for more details.)
           Please file a bug at http://issuetracker.google.com/issues/new?component=460323.
 
* 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 3m 31s
Running Gradle task 'assembleRelease'...
Running Gradle task 'assembleRelease'... Done                     216.4s (!)
Gradle task assembleRelease failed with exit code 1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

FAILURE: Build failed with an exception.

* What went wrong:

Execution failed for task ':app:lintVitalRelease'.

> Could not resolve all artifacts for configuration ':app:debugRuntimeClasspath'.

   > Failed to transform libs.jar to match attributes {artifactType=processed-jar, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}.

      > Execution failed for JetifyTransform: /Users/aaaa/a-master/example/build/app/intermediates/flutter/debug/libs.jar.

         > Failed to transform '/Users/aaaa/a-master/example/build/app/intermediates/flutter/debug/libs.jar' using Jetifier. Reason: FileNotFoundException, message: /Users/aaaa/a-master/example/build/app/intermediates/flutter/debug/libs.jar (No such file or directory). (Run with --stacktrace for more details.)

           Please file a bug at http://issuetracker.google.com/issues/new?component=460323.

* 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 3m 31s

Running Gradle task 'assembleRelease'...

Running Gradle task 'assembleRelease'... Done                     216.4s (!)

Gradle task assembleRelease failed with exit code 1

解决方法

注释掉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' }

如果还是不行的话,试试下面那个

或者还有一种方法就是

点一下这里再点运行试试看 

 

### 解决 Gradle 构建中 'Could not resolve all files for configuration :app:debugRuntimeClasspath' 错误 当遇到 `Could not resolve all files for configuration ':app:debugRuntimeClasspath'` 的错误时,通常意味着 Gradle 在尝试解析项目所需的依赖项时遇到了问题。以下是几种常见的解决方案: #### 检查网络连接和仓库配置 确保开发机器具有稳定的互联网连接,并且可以访问远程 Maven 或 JCenter 仓库。如果使用的是公司内部网或者有代理设置,则需确认这些设置已正确配置于项目的 `gradle.properties` 文件中。 对于 Android Studio Hedgehog | 2023.1.1 版本而言,建议在 Project 的 build.gradle 中添加 Google 和 jcenter 库作为插件源[^1]: ```groovy allprojects { repositories { google() mavenCentral() // 替代jcenter(),因为JFrog宣布关闭了JCenter服务. } } ``` #### 更新依赖版本号并清理缓存 有时特定版本的库可能不再可用或已被删除;因此应该更新至最新稳定版来解决问题。另外还可以通过执行命令 `./gradlew cleanBuildCache` 来清除本地构建缓存数据以排除潜在冲突因素。 #### 查看具体未解析成功的依赖路径 查看完整的堆栈跟踪日志可以帮助定位确切哪个依赖未能成功加载。这有助于进一步调查该依赖是否存在以及其URL地址是否发生变化等问题。 #### 验证依赖声明语法准确性 仔细核对所有模块下的 dependencies 块内的语句书写无误,特别是注意大小写敏感性和分隔符等细节之处。例如,在引入 MQTT 客户端时应按照官方文档指导正确指定 group ID, artifact ID 及 version 参数值[^2]: ```groovy implementation 'org.eclipse.paho:org.eclipse.paho.client.mqttv3:<latest_version>' ``` #### 尝试同步项目结构与 Gradle 设置 点击菜单栏中的 Sync Now 按钮让 IDE 自动调整文件夹布局使之匹配当前使用的 Gradle 插件特性集。此外也可以重启IDE试试能否恢复正常工作状态。 #### 调整 Gradle 编译选项 适当修改 gradle-wrapper.properties 文件里的 distributionUrl 属性指向较新一点的大版本系列,比如升级到7.x系以上可能会带来性能提升的同时也解决了部分旧版遗留下来的兼容性难题。 #### 使用 Flutter 开发环境特有条件处理方法 如果是Flutter工程的话除了上述措施外还需额外留意 pubspec.yaml 文件里 packages 列表定义情况,同时运行 flutter doctor --android-licenses 接受许可协议以防因权限不足引起异常状况发生[^3].
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值