自定义Maven仓库依赖报错:无法解析:app:debugRuntimeClasspath配置
依赖配置问题:无法解析com.serenegiant:common:4.1.1依赖
问题背景
我需要使用指定仓库中的aar包,项目根目录build.gradle配置如下:
buildscript { repositories { google() mavenCentral() maven { url 'https://raw.github.com/saki4510t/libcommon/master/repository/' } } dependencies { classpath 'com.android.tools.build:gradle:7.4.2' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } }
App模块的build.gradle配置:
implementation("com.serenegiant:common:4.1.1") { exclude module: 'support-v4' }
这套配置在一个项目中能正常工作,但在另一个项目里持续报错:
Execution failed for task ':app:mergeDebugNativeLibs'. > Could not resolve all files for configuration ':app:debugRuntimeClasspath'. > Could not find com.serenegiant:common:4.1.1. Searched in the following locations: - https://dl.google.com/dl/android/maven2/com/serenegiant/common/4.1.1/common-4.1.1.pom - https://repo.maven.apache.org/maven2/com/serenegiant/common/4.1.1/common-4.1.1.pom - https://jitpack.io/com/serenegiant/common/4.1.1/common-4.1.1.pom Required by: project :app
已经尝试过重建项目、清理缓存、重启Android Studio,问题依旧存在,找不到两个项目的配置差异,希望得到排查提示。
更新[2023-05-23]
运行命令 ./gradlew --info --refresh-dependencies 后,正常项目中出现如下错误:
> Could not resolve all files for configuration ':classpath'. > Could not resolve com.android.tools.build:gradle:7.4.2. Required by: project : > No matching variant of com.android.tools.build:gradle:7.4.2 was found. The consumer was configured to find a runtime of a library compatible with Java 8, packaged as a jar, and its dependencies declared externally, as well as attribute 'org.gradle.plugin.api-version' with value '7.5' but: - Variant 'apiElements' capability com.android.tools.build:gradle:7.4.2 declares a library, packaged as a jar, and its dependencies declared externally: - Incompatible because this component declares an API of a component compatible with Java 11 and the consumer needed a runtime of a component compatible with Java 8 - Other compatible attribute: - Doesn't say anything about org.gradle.plugin.api-version (required '7.5') - Variant 'javadocElements' capability com.android.tools.build:gradle:7.4.2 declares a runtime of a component, and its dependencies declared externally: - Incompatible because this component declares documentation and the consumer needed a library - Other compatible attributes: - Doesn't say anything about its target Java version (required compatibility with Java 8) - Doesn't say anything about its elements (required them packaged as a jar) - Doesn't say anything about org.gradle.plugin.api-version (required '7.5') - Variant 'runtimeElements' capability com.android.tools.build:gradle:7.4.2 declares a runtime of a library, packaged as a jar, and its dependencies declared externally: - Incompatible because this component declares a component compatible with Java 11 and the consumer needed a component compatible with Java 8 - Other compatible attribute: - Doesn't say anything about org.gradle.plugin.api-version (required '7.5') - Variant 'sourcesElements' capability com.android.tools.build:gradle:7.4.2 declares a runtime of a component, and its dependencies declared externally: - Incompatible because this component declares documentation and the consumer needed a library - Other compatible attributes: - Doesn't say anything about its target Java version (required compatibility with Java 8) - Doesn't say anything about its elements (required them packaged as a jar) - Doesn't say anything about org.gradle.plugin.api-version (required '7.5')
更新[2023-05-24]
更奇怪的是:将依赖版本改为com.serenegiant:common:2.1.1时,Android Studio会提示有新版本可用,说明能识别该依赖,但就是无法获取4.1.1版本。
内容的提问来源于stack exchange,提问作者Hong
相关产品推荐
相关产品推荐

