Gradle无法找到模块依赖的传递依赖

时间:2015-12-05 00:26:32

标签: android android-studio intellij-idea android-gradle

我有一个包含两个Android Gradle模块的项目:一个库:mylib和一个应用:demo。在build.gradle :demo中,我添加了对:mylib的依赖:

dependencies {
    compile project(':mylib')
}

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

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

在我将:mylib模块添加到项目之前,正确设置了repo,: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,更不用说为什么它会尝试解决依赖本身。我并不认为public中有protected甚至:mylib的任何内容会暴露其对ksoap2的使用。

1 个答案:

答案 0 :(得分:1)

由于您包含模块,gradle正在尝试解析所有嵌套依赖项(类似于pom文件的somenthing)。

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

只需添加gradle可以找到此库的存储库。

相关问题