背景:项目有2个 Module, 一个app,一个xxx
在xxx Module中使用了aar库,且在build.gradle中按如下配置
repositories {
flatDir {
dirs 'libs'
}
}
dependencies {
implementation(name: 'xxx-sdk', ext: 'aar')
}写代码时,库中的类、方法均可正常引用,但编译报错
Execution failed for task ':app:preDevReleaseBuild'. > Could not resolve all files for configuration ':app:devReleaseRuntimeClasspath'. > Could not find :xxx-sdk:. Required by: project :app > project :xxx Possible solution: - Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html
解决方法
到最外层的项目 build.gradle中添加如下代码
allprojects {
repositories {
google()
jcenter()
flatDir {
dirs project(':xxx').file('libs')
}
}
}即把flatDir这部分写到这里来,project中xxx即为使用aar的那个module的名称


鄂公网安备 42018502001427号
发表评论