问题是实现具有依赖关系的gradle多项目

时间:2017-12-14 21:41:23

标签: android gradle android-gradle android-gradle-3.0

我有一个gradle项目,其中包含我的app,然后是我的lib。我在尝试构建app模块时遇到错误,因为它无法找到lib模块所需的依赖项。

* What went wrong:
Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
Could not find com.google.android.gms:play-services-location:11.4.2.
Searched in the following locations:
  file:/Users/me/Library/Android/sdk/extras/m2repository/com/google/android/gms/play-services-location/11.4.2/play-services-location-11.4.2.pom
  file:/Users/me/Library/Android/sdk/extras/m2repository/com/google/android/gms/play-services-location/11.4.2/play-services-location-11.4.2.jar
  file:/Users/me/Library/Android/sdk/extras/google/m2repository/com/google/android/gms/play-services-location/11.4.2/play-services-location-11.4.2.pom
  file:/Users/me/Library/Android/sdk/extras/google/m2repository/com/google/android/gms/play-services-location/11.4.2/play-services-location-11.4.2.jar
  file:/Users/me/Library/Android/sdk/extras/android/m2repository/com/google/android/gms/play-services-location/11.4.2/play-services-location-11.4.2.pom
  file:/Users/me/Library/Android/sdk/extras/android/m2repository/com/google/android/gms/play-services-location/11.4.2/play-services-location-11.4.2.jar

Required by:
  project :app > project :lib

此错误对于所有lib模块的依赖项都是重复的。我目前在存储库下的lib/build.gradle中定义了这些依赖项。

repositories {
    jcenter()
    google()
    maven { url "https://jitpack.io" }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.google.android.gms:play-services-location:11.4.2'
    implementation 'com.google.android.gms:play-services-gcm:11.4.2'
    // ...
}
// ...

当我运行./gradlew lib:assembleDebug时,我收到了lib构建的成功消息。所以我知道存储库/依赖关系定义对于该模块是正确的。不幸的是,构建应用程序无法获得所需的结果:

./gradlew assembleDebug --rerun-tasks --console plain
:buildSrc:compileJava NO-SOURCE
:buildSrc:compileGroovy
:buildSrc:processResources NO-SOURCE
:buildSrc:classes
:buildSrc:jar
:buildSrc:assemble
:buildSrc:compileTestJava NO-SOURCE
:buildSrc:compileTestGroovy NO-SOURCE
:buildSrc:processTestResources NO-SOURCE
:buildSrc:testClasses UP-TO-DATE
:buildSrc:test NO-SOURCE
:buildSrc:check UP-TO-DATE
:buildSrc:build
The CompileOptions.bootClasspath property has been deprecated and is scheduled to be removed in Gradle 5.0. Please use the CompileOptions.bootstrapClasspath property instead.
:app:customTask
:app:preBuild
:lib:preBuild UP-TO-DATE
:lib:preDebugBuild UP-TO-DATE
:lib:checkDebugManifest
:lib:processDebugManifest
:app:preDebugBuild FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
> Could not find com.google.android.gms:play-services-location:11.4.2.
// ... 

我在preBuild任务之前注入的app模块中有一些任务。我不认为这会导致事情被抛弃,但为了以防万一,我会提到它。

如果有人对实施多项目gradle app有任何建议,子项目定义了自己的存储库,我将非常感激。

0 个答案:

没有答案