gradle clean报错Could not find manifest-merger.jar

本文解决了一个关于Android项目中使用Gradle构建时遇到的问题,主要原因是未能找到必要的依赖库,如manifest-merger.jar等。通过调整build.gradle文件中仓库源的顺序,将google()置于jcenter()之前,成功解决了构建失败的问题。

wangpan@wangpan-OptiPlex-7050:~/work/gitnew/camera-bokeh/bokeh_android$ gradle clean

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'bokeh_android'.
> Could not resolve all files for configuration ':classpath'.
   > Could not find manifest-merger.jar (com.android.tools.build:manifest-merger:26.1.1).
     Searched in the following locations:
         https://jcenter.bintray.com/com/android/tools/build/manifest-merger/26.1.1/manifest-merger-26.1.1.jar
   > Could not find ddmlib.jar (com.android.tools.ddms:ddmlib:26.1.1).
     Searched in the following locations:
         https://jcenter.bintray.com/com/android/tools/ddms/ddmlib/26.1.1/ddmlib-26.1.1.jar
   > Could not find dvlib.jar (com.android.tools:dvlib:26.1.1).
     Searched in the following locations:
         https://jcenter.bintray.com/com/android/tools/dvlib/26.1.1/dvlib-26.1.1.jar
   > Could not find common.jar (com.android.tools:common:26.1.1).
     Searched in the following locations:
         https://jcenter.bintray.com/com/android/tools/common/26.1.1/common-26.1.1.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
 

参考:https://stackoverflow.com/questions/50563783/could-not-find-manifest-merger-jar-com-android-tools-buildmanifest-merger26-1

 

把工程根目录下面的build.gradle文件里面的google()和jcenter()交换顺序,保证google()在前面。

A problem occurred configuring root project 'ApeFTM_realme_chrome'. > Could not resolve all artifacts for configuration 'classpath'. > Could not find sdk-common-31.8.0.jar (com.android.tools:sdk-common:31.8.0). Searched in the following locations: https://mirrors.cloud.tencent.com/maven/com/android/tools/sdk-common/31.8.0/sdk-common-31.8.0.jar > Could not find sdklib-31.8.0.jar (com.android.tools:sdklib:31.8.0). Searched in the following locations: https://mirrors.cloud.tencent.com/maven/com/android/tools/sdklib/31.8.0/sdklib-31.8.0.jar > Could not find gradle-api-8.8.0.jar (com.android.tools.build:gradle-api:8.8.0). Searched in the following locations: https://mirrors.cloud.tencent.com/maven/com/android/tools/build/gradle-api/8.8.0/gradle-api-8.8.0.jar > Could not find crash-31.8.0.jar (com.android.tools.analytics-library:crash:31.8.0). Searched in the following locations: https://mirrors.cloud.tencent.com/maven/com/android/tools/analytics-library/crash/31.8.0/crash-31.8.0.jar > Could not find tracker-31.8.0.jar (com.android.tools.analytics-library:tracker:31.8.0). Searched in the following locations: https://mirrors.cloud.tencent.com/maven/com/android/tools/analytics-library/tracker/31.8.0/tracker-31.8.0.jar > Could not find android-device-provider-profile-proto-31.8.0.jar (com.android.tools.utp:android-device-provider-profile-proto:31.8.0). Searched in the following locations: https://mirrors.cloud.tencent.com/maven/com/android/tools/utp/android-device-provider-profile-proto/31.8.0/android-device-provider-profile-proto-31.8.0.jar > Could not find builder-model-8.8.0.jar (com.android.tools.build:builder-model:8.8.0). Searched in the following locations: https://mirrors.cloud.tencent.com/maven/com/android/tools/build/builder-model/8.8.0/builder-model-8.8.0.jar > Could not find guava-32.0.1-jre.jar (com.google.guava:guava:32.0.1-jre). Searched in the following locations: https://mirrors.cloud.tencent.com/maven/com/google/guava/guava/32.0.1-jre/guava-32.0.1-jre.jar > Could not find annotations-23.0.0.jar (org.jetbrains:annotations:23.0.0). Searched in the following locations: https://mirrors.cloud.tencent.com/maven/org/jetbrains/annotations/23.0.0/annotations-23.0.0.jar Possible solution: - Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html
07-26
你遇到的这个 Gradle 构建错误: ``` A problem occurred configuring root project 'ApeFTM_realme_chrome'. > Could not resolve all artifacts for configuration 'classpath'. > Could not find sdk-common-31.8.0.jar ... ``` 说明 Gradle 在尝试下载项目构建所需的依赖库(如 Android Gradle 插件)时失败了,**所有依赖都只在腾讯云镜像中查找,但该镜像中没有这些库的对应版本**。 --- ## 一、问题原因 ### 1. **依赖版本不存在于腾讯云镜像中** - 你使用的依赖版本(如 `31.8.0`)并不是标准的 Android 工具版本,可能是误写或仅存在于 Google 官方仓库。 - 腾讯云镜像可能没有同步这些版本,或这些版本根本不存在。 ### 2. **仓库配置错误** - 你的项目配置了仅使用腾讯云镜像仓库,而没有使用官方的 Google 仓库,导致无法找到这些依赖。 --- ## 二、解决方案 ### ✅ 方法一:使用 Google 官方仓库(推荐) 修改你的项目级 `build.gradle` 和 `settings.gradle` 文件,确保使用官方仓库。 ### 1. 修改 `build.gradle`(项目级) ```groovy buildscript { repositories { google() // 使用 Google 官方仓库 mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:8.8.0' } } ``` ### 2. 修改 `settings.gradle` ```groovy dependencyResolutionManagement { repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) repositories { google() mavenCentral() } } ``` --- ### ✅ 方法二:确认 Android Gradle 插件版本是否正确 你使用了: ```groovy classpath 'com.android.tools.build:gradle:8.8.0' ``` 这表示你使用的是 **Android Gradle 插件 8.8.0**,它是与 **Gradle 8.6 - 8.9** 兼容的版本。 请确保你的 `gradle-wrapper.properties` 中使用的 Gradle 版本与插件版本匹配: ```properties distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip ``` > ✅ 推荐使用 Gradle 8.6 或 8.8,避免使用 9.0 以上版本,除非你项目已升级到 Android U。 --- ## 三、常见兼容性对照表(AGP 与 Gradle) | Android Gradle 插件版本 | 推荐 Gradle 版本 | |--------------------------|------------------| | 7.2.x | 7.3.3 / 7.4.2 | | 7.4.x | 7.5 | | 8.0.x | 8.0 | | 8.1.x | 8.2 | | 8.3.x | 8.3 | | 8.6.x | 8.6 | | 8.8.x | 8.8 | --- ## 四、额外建议 ### 1. 清除 Gradle 缓存(可选) ```bash # Windows rd /s /q %USERPROFILE%\.gradle\caches\ ``` ```bash # Linux / macOS rm -rf ~/.gradle/caches/ ``` 然后重新构建项目。 ### 2. 使用国内镜像(如果必须使用镜像) 如果你仍然想使用国内镜像,请使用阿里云: ```groovy repositories { maven { url 'https://maven.aliyun.com/repository/public' } google() mavenCentral() } ``` --- ## 五、最终建议配置示例 ### `build.gradle`(项目级) ```groovy buildscript { repositories { google() mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:8.8.0' } } ``` ### `gradle/wrapper/gradle-wrapper.properties` ```properties distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip ``` --- ##
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值