-2

hi i'm trying to migrate Glide library from 3.8.0 to 4.5.0 after update i get this warning:

All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 27.0.2, 26.1.0. Examples include com.android.support:support-compat:27.0.2 and com.android.support:animated-vector-drawable:26.1.0

my build.gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    buildToolsVersion '26.0.2'
    dexOptions {
        preDexLibraries = false
        javaMaxHeapSize "4g"
    }
    defaultConfig {
        applicationId "maa.myapp"
        minSdkVersion 15
        targetSdkVersion 26
        versionCode 45
        versionName "4.1.1"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}
android {
    packagingOptions {
        exclude 'META-INF/DEPENDENCIES.txt'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/dependencies.txt'
        exclude 'META-INF/LGPL2.1'
    }
}
android {
    configurations.all {
        resolutionStrategy.force 'com.google.code.findbugs:jsr305:1.3.9'
    }
}
dependencies {
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    //notifications
    compile 'com.android.support:recyclerview-v7:26.1.0'
    compile 'com.android.support:appcompat-v7:26.1.0'
    compile 'com.android.support:design:26.1.0'
    compile 'com.github.chrisbanes:PhotoView:2.1.3'
    compile 'com.android.support:cardview-v7:26.1.0'
    compile 'com.android.volley:volley:1.0.0'
    compile 'com.android.support:multidex:1.0.2'
    compile 'com.android.support:support-v4:26.1.0'
    compile 'com.github.bumptech.glide:glide:4.5.0'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.nineoldandroids:library:2.4.0'
    compile 'com.daimajia.slider:library:1.1.5@aar'
    compile 'com.google.android.gms:play-services-ads:11.8.0'
    compile 'com.google.firebase:firebase-core:11.8.0'
    compile 'com.google.firebase:firebase-messaging:11.8.0'
    compile 'com.firebase:firebase-jobdispatcher:0.6.0'
    compile 'com.vodyasov:amr:0.5'
    compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.7'
    compile 'com.google.guava:guava:23.6-android'
    testCompile 'junit:junit:4.12'
    compile 'com.squareup:otto:1.3.8'
}
apply plugin: 'com.google.gms.google-services'
Zoe
  • 27,060
  • 21
  • 118
  • 148
ali
  • 189
  • 3
  • 14

4 Answers4

2

You should exclude support library from Glide, if you don't want to move to support library 27

dependencies {
   compile ("com.github.bumptech.glide:glide:4.5.0") {
          exclude group: "com.android.support"
   }
   ...
}

From Glide documentation:

Support Library Version - Glide uses support library version 27.

If you need or would prefer to use a different version of the support library you should exclude "com.android.support" from your Glide dependency in your build.gradle file.

DeKaNszn
  • 2,720
  • 3
  • 26
  • 26
1

Run gradlew app:dependencies command and you get below output.

+--- com.google.firebase:firebase-appindexing:11.8.0 | +--- com.google.android.gms:play-services-base:11.8.0 | | +--- com.google.android.gms:play-services-basement:11.8.0 | | |
+--- com.android.support:support-v4:25.2.0 | | | | +--- com.android.support:support-compat:25.2.0 -> 27.0.1 () | | |
| +--- com.android.support:support-media-compat:25.2.0 | | | | | +--- com.android.support:support-annotations:25.2.0 -> 27.0.1 | | | | | --- com.android.support:support-compat:25.2.0 -> 27.0.1 (
) | | |
| +--- com.android.support:support-core-utils:25.2.0 -> 27.0.1 () | | | | +--- com.android.support:support-core-ui:25.2.0 -> 27.0.1 () | | | | --- com.android.support:support-fragment:25.2.0 -> 27.0.1 (*) | | | --- com.google.android.gms:play-services-basement-license:11.8.0 |
| +--- com.google.android.gms:play-services-tasks:11.8.0

Notice the version difference for support library in firebase.

com.android.support:support-compat:25.2.0 -> 27.0.1 (*)

you can see this for all your library version mismatch so, to solve this problem you can repeat below step for all mismatch library version

replace this compile 'com.github.bumptech.glide:glide:4.5.0'

with below code

compile ('com.github.bumptech.glide:glide:4.5.0',{
    exclude group: 'com.android.support'   
})
Bhavesh Desai
  • 753
  • 4
  • 20
  • I think @bhavesh-desai gave a better answer than the accepted one. His answer shall deserve more up-vote. I would like to further explains the steps as I followed his answer. Run the `gradlew` command and save the output to a text, that will help you in narrowing down the problem. Then, you search for the lower version number (for example 26.1.0) You will find "Dependency-A" included an older version of support library. Exclude that one. And add it back with the higher version number. – John Pang Mar 15 '18 at 11:59
0

This warning comes when a library is being referred in the same project but with different versions.

Now to go in deep to find out which different versions of libraries are being used by project, just run the following command and you will get a complete tree of dependencies:

./gradlew app:dependencies
Paresh Mayani
  • 127,700
  • 71
  • 241
  • 295
0

With the release the of Glide 4.0.0 RC0, glide starts to use support library version 27. Right now, the stable version available of Glide is Glide 4.5.0 which is using following dependencies,

com.android.support:support-annotations:27.0.2
com.android.support:support-compat:27.0.2
com.android.support:support-core-ui:27.0.2
com.android.support:support-core-utils:27.0.2
com.android.support:support-fragment:27.0.2

This dependencies are from support library version 27, while you using support version 26. That's why Android SDK showing a warning, because Glide 4.5.0 is internally using support library version 27.

Now there are two solutions either you use support library version 27 in your project or exclude support library version from Glide as,

dependencies {
   compile ("com.github.bumptech.glide:glide:4.5.0") {
          exclude group: "com.android.support"
}
Aditya
  • 3,525
  • 1
  • 31
  • 38