gradle 库与应用程序模块的集成问题
Issue with gradle library integration with app module
我刚刚将我的 Eclipse Android
项目移动到 Android Studio
,我有一个应用程序模块和一个库模块。
库模块在其 build.gradle
中包含一些 3rd party dependencies
,如下所示:
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
如何解决此依赖项的问题?
您必须在主模块中克隆 repo 信息。
主模块必须知道它必须下载依赖项的 Maven 存储库。
然后在mainModule/build.gradle
中加入
repositories {
maven {
url "https://api.bitbucket.org/1.0/repositories/3_party
credentials{
username 'XXXXXX'
password 'XXXXXX'
}
}
}
我刚刚将我的 Eclipse Android
项目移动到 Android Studio
,我有一个应用程序模块和一个库模块。
库模块在其 build.gradle
中包含一些 3rd party dependencies
,如下所示:
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
如何解决此依赖项的问题?
您必须在主模块中克隆 repo 信息。
主模块必须知道它必须下载依赖项的 Maven 存储库。
然后在mainModule/build.gradle
repositories {
maven {
url "https://api.bitbucket.org/1.0/repositories/3_party
credentials{
username 'XXXXXX'
password 'XXXXXX'
}
}
}