how to force to use the com.google.android.gms:play-services:15.0.0

177 views Asked by At

having an app which has dependency on a lib, that lib has dependency:

api "com.google.android.gms:play-services:11.0.2"

in this app it wants to use com.google.android.gms:play-services-maps:15.0.1, so it did these is gradle:

implementation ('com.google.android.gms:play-services-maps:15.0.1') { force = true }

which triggers the download and also

configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
    def requested = details.requested

    if (details.requested.group == 'com.google.android.gms' && requested.name.contains('play-services-maps')) {
        details.useVersion "15.0.1"
    }

    /*
    // this causes build error that cannot relsove the xxx-15.0.0
    //
    if (requested.name.contains('play-services')
            && VersionNumber.parse(requested.version) < VersionNumber.parse(15.0.0)
        ) {
        details.useVersion "15.0.0"
    }
    */
}
}

in the dependency graph, it shows:

dogfoodRuntimeClasspath - Dependencies for runtime/packaging

+--- com.google.android.gms:play-services-maps:15.0.1@aar

But at runtime still crashes at where it reference to LatLng

NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/maps/model/LatLng

which is from play-services-maps:15.0.1

Question 1: Why is that, and how to force to use the 15.0.1 version?

2: Seems since no one is having dependency on "com.google.android.gms:play-services:15.0.0", the part:

/*
// this causes build error that cannot relsove the xxx-15.0.0
//
if (requested.name.contains('play-services')
        && VersionNumber.parse(requested.version) < VersionNumber.parse(15.0.0)
    ) {
    details.useVersion "15.0.0"
}
*/

will find the requested.version==11.0.2 and try to replace with 15.0.0, but that will cause failure that cannot resolve the play-service-xxx:15.0.0.

Is it because the resolutionStrategy only replace the version number but will not download the files?

0

There are 0 answers