Project requires same repositories defined as library module


(Austin Treat Emmons) #1

I have an app module and a lib module. I would like the lib module to be completely distinct from the app module.

Currently the lib module is responsible for defining the repositories and dependencies it uses. When I try to build the app project, which uses the lib module as a project dependency I get errors:

Could not resolve all files for configuration ':app:debugCompileClasspath'
>  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

If in my rootProject, I add the same repository definitions as in my lib project, but under the allProjects configuration, the build succeeds. I don’t want to do this though as it couples the projects in a way that I don’t want. It also makes the lib project’s dependencies harder to change.

Here’s a sample project that I’ve narrowed this down to the barebones. I’ve been running

gradle assembleDebug

to perform the build.

test-gradle.zip (370.1 KB)


(Austin Treat Emmons) #2

I’ve also created an issue in Google’s issue tracker.
https://issuetracker.google.com/issues/70815519