Android编译报错 > Could not find :xxx Required by: project :app > project :xxx

2021-07-29 17:25:11  阅读 4159 次 评论 0 条

背景:项目有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的名称

本文地址:http://bloguan.com/?id=564
版权声明:本文为原创文章,版权归 博观网 所有,欢迎分享本文,转载请保留出处!

发表评论


表情

还没有留言,还不快点抢沙发?