在我的情况下,必须分发 aar。当我在另一个项目中导入 aar 时,会出现此错误。我解决了这个问题,使用 maven 依赖结构(pom、md5 等)分发 aar
publishing {
publications {
maven(MavenPublication) {
groupId "<GROUP_ID>"
artifactId "<ARTIFACT_ID>"
version <VERSION>
artifact "$buildDir/outputs/aar/<AAR_FILE>"
pom.withXml {
def dependenciesNode = asNode().appendNode("dependencies")
configurations.compile.allDependencies.each { dependency ->
def dependencyNode = dependenciesNode.appendNode("dependency")
dependencyNode.appendNode("groupId", dependency.group)
dependencyNode.appendNode("artifactId", dependency.name)
dependencyNode.appendNode("version", dependency.version)
}
}
}
}
repositories {
maven {
url "$buildDir/repo"
}
}
}
在 android 应用程序上,我需要添加本地 maven 存储库:
allprojects {
repositories {
jcenter()
maven {
url "<LOCAL_REPO>"
}
}
}
并添加依赖:
compile("<GROUP_ID>:<ARTIFACT_ID>:<VERSION>@aar") {
transitive = true
}