我有一个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有任何建议,子项目定义了自己的存储库,我将非常感激。