5

I recently changed my build.gradle files to use implementation instead of compile. The implementation keyword forces you to make sure that all of your dependencies are with the same version.

Apperantly the google maps dependency 'com.google.android.gms:play-services-maps:12.0.1' is using an older version of the support library (26.1.0)

I was able to diagnose the issue after running ./gradlew dependencies -b app/build.gradle

Here is the output:

+--- com.google.android.gms:play-services-maps:12.0.1
|    +--- com.google.android.gms:play-services-base:12.0.1
|    |    +--- com.google.android.gms:play-services-basement:12.0.1
|    |    |    +--- com.android.support:support-v4:26.1.0
|    |    |    |    +--- com.android.support:support-compat:26.1.0 -> 27.1.0 (*)
|    |    |    |    +--- com.android.support:support-media-compat:26.1.0
|    |    |    |    |    +--- com.android.support:support-annotations:26.1.0 -> 27.1.0
|    |    |    |    |    \--- com.android.support:support-compat:26.1.0 -> 27.1.0 (*)
|    |    |    |    +--- com.android.support:support-core-utils:26.1.0 -> 27.1.0 (*)
|    |    |    |    +--- com.android.support:support-core-ui:26.1.0 -> 27.1.0 (*)
|    |    |    |    \--- com.android.support:support-fragment:26.1.0 -> 27.1.0 (*)

The question is: is there a solution to this situation? I know that using compile instead of implementation solves the problem, but compile will be removed in 2019.

Here is the build.gradle file:

apply plugin: 'com.android.application'
android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "com.test.myapplication"
        minSdkVersion 14
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:27.1.0'
    implementation 'com.google.android.gms:play-services-maps:12.0.1'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}
user1940676
  • 4,348
  • 9
  • 44
  • 73
  • 2
    You can restrict the support lib version try to use `resolutionStrategy` Follow https://stackoverflow.com/a/49596276/4168607 or similar. – ADM Apr 02 '18 at 15:09
  • "I know that using compile instead of implementation solves the problem" -- not that I am aware of. Add `implementation` for `support-v4` for `27.1.0` to force the upgrade of that artifact. Then, hope that Google not only updates their libraries, but also uses smaller/less-obsolete artifacts than `support-v4`. – CommonsWare Apr 02 '18 at 15:11
  • Use ***'api'*** when you face such a situation here is the better explanation https://medium.com/mindorks/implementation-vs-api-in-gradle-3-0-494c817a6fa – xelvias.exe Sep 06 '18 at 20:48

0 Answers0