gradle库与app模块集成的问题

时间:2015-08-12 06:14:49

标签: android android-studio gradle android-gradle build.gradle

我刚将Eclipse Android项目移至Android Studio,我有一个App模块和一个图书馆模块。

图书馆模块在其3rd party dependencies中包含一些build.gradle,如下所示:

repositories {
    maven {
        url "https://api.bitbucket.org/1.0/repositories/3_party
        credentials{
            username 'XXXXXX'
            password 'XXXXXX'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    //compile 'com.android.support:appcompat-v7:22.2.1'
    compile 'com.xxx.sdk:'
}

现在库项目编译得很好,它也可以从存储库中获取它的依赖项,在这种情况下是bitbucket。

但是一旦我在App模块中包含库模块,我就开始收到一个错误,其中app模块试图解析3rd party dependency,而应由库来解决,

Could not resolve all dependencies for configuration ':xxxx:_debugCompile'.
   > Could not find com.xxxx.sdk:sdk:1.0.0.
     Searched in the following locations:
         https://jcenter.bintray.com/com/xxx/sdk/sdk/1.0.0/sdk-1.0.0.pom
         https://jcenter.bintray.com/com/xxx/sdk/sdk/1.0.0/sdk-1.0.0.aar 

如何修复此依赖项的问题?

1 个答案:

答案 0 :(得分:1)

您必须克隆主模块中的回购信息 主模块必须知道必须下载依赖项的maven repo。

然后添加mainModule/build.gradle

repositories {
    maven {
        url "https://api.bitbucket.org/1.0/repositories/3_party
        credentials{
            username 'XXXXXX'
            password 'XXXXXX'
        }
    }
}