2015-12-05 217 views
0

我有一个项目有两个Android Gradle模块:一个库,:mylib和一个应用程序,:demo。在build.gradle:demo,我添加了一个依赖于:mylibGradle无法找到传递依赖关系模块依赖

dependencies { 
    compile project(':mylib') 
} 

反过来,:mylib有这种依赖性:

dependencies { 
    compile 'com.google.code.ksoap2-android:ksoap2-android:3.5.0' 
} 

回购设置正确,并:mylib建立了良好之前我添加了:demo模块到项目。但现在当我建,我得到这个:

Error:Gradle: A problem occurred configuring project ':demo'. 
> Could not resolve all dependencies for configuration ':demo:_debugCompile'. 
    > Could not find com.google.code.ksoap2-android:ksoap2-android:3.5.0. 
    Searched in the following locations: 
     https://jcenter.bintray.com/com/google/code/ksoap2-android/ksoap2-android/3.5.0/ksoap2-android-3.5.0.pom 
     https://jcenter.bintray.com/com/google/code/ksoap2-android/ksoap2-android/3.5.0/ksoap2-android-3.5.0.jar 
     file:/home/kevin/local/android-sdk-linux/extras/android/m2repository/com/google/code/ksoap2-android/ksoap2-android/3.5.0/ksoap2-android-3.5.0.pom 
     file:/home/kevin/local/android-sdk-linux/extras/android/m2repository/com/google/code/ksoap2-android/ksoap2-android/3.5.0/ksoap2-android-3.5.0.jar 
     file:/home/kevin/local/android-sdk-linux/extras/google/m2repository/com/google/code/ksoap2-android/ksoap2-android/3.5.0/ksoap2-android-3.5.0.pom 
     file:/home/kevin/local/android-sdk-linux/extras/google/m2repository/com/google/code/ksoap2-android/ksoap2-android/3.5.0/ksoap2-android-3.5.0.jar 
    Required by: 
     MyProject:demo:unspecified > MyProject:mylib:unspecified 

我不明白为什么:demo甚至知道:mylib使用kso​​ap2,更不用说为什么它会尝试解决的依赖本身。我不认为在:mylib中有任何public甚至protected,揭示了它使用kso​​ap2。

回答

0

既然你是包括模块,gradle这个正试图解决所有嵌套的相关(somenthing类似于POM文件)。

com.google.code.ksoap2-android不在jcenter或maven中央存储库中,这是您问题的原因。

只需添加gradle可以找到该库的库。

+0

那么我的模块没有办法不公开自己解决的依赖关系? –

+1

在maven仓库中发布库也是一样。该库不会包含将包含在pom文件中的嵌套dependencies。在这种情况下,主项目也将解决嵌套的依赖关系。 –

+0

啊。我在Eclipse工作区中概念化了一个模块依赖项,如项目依赖项。我期待它像一个超级罐子一样对待。 –