我刚刚将我的 Eclipse Android
项目移动到 Android Studio
,我有一个 App 模块和一个 Library 模块。
库模块在其 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 模块试图解析 第三方依赖项
,而这应该由库来解析,
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
如何解决此依赖项的问题?
最佳答案
你必须在你的主模块中克隆 repo 信息。
主模块必须知道它必须下载依赖项的 Maven 存储库。
然后在mainModule/build.gradle
中添加
repositories {
maven {
url "https://api.bitbucket.org/1.0/repositories/3_party
credentials{
username 'XXXXXX'
password 'XXXXXX'
}
}
}
关于android - gradle 库与应用程序模块集成的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31957322/