I've got a gradle project that contains my app
and then my lib
. I'm seeing errors when trying to build my app
module because it can't find the dependencies needed by the lib
module.
* 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
This error is duplicative for all of the lib
module's dependencies. I currently have these dependencies defined in lib/build.gradle
under the repositories.
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'
// ...
}
// ...
When I run ./gradlew lib:assembleDebug
I get a success message that the lib has built. So I know that the repositories/dependencies definitions are correct for that module. Unfortunately building the app doesn't get the desired results:
./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.
// ...
I do have some tasks in the app module that I inject before the preBuild task. I don't think this is causing things to be thrown off but I'll mention it just in case.
If anyone has any suggestions on implementing a multi-project gradle app where a subproject defines its own repositories I'd be very thankful.