Oriz
Oriz

Reputation: 27

Libraries must use same version error

I am getting this error whenever I add the Glide library to the app.gradle and I can't get rid of it.

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

There are some combinations of libraries, or tools and libraries, that are incompatible, or can lead to bugs. One such incompatibility is compiling with a version of the Android support libraries that is not the latest version (or in particular, a version lower than your targetSdkVersion.)

The build file looks like this:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "com.example.david.six_month"
        minSdkVersion 15
        multiDexEnabled true
        targetSdkVersion 26
        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:26.1.0'
    implementation 'com.android.support:support-v4:26.1.0'


    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    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'
    implementation 'commons-net:commons-net:3.6'
    implementation 'com.github.bumptech.glide:glide:4.7.1'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.7.1'
}

Upvotes: 1

Views: 2059

Answers (6)

Ashok Chowdary
Ashok Chowdary

Reputation: 147

This error because of Glide library.Try picasso image loader or other image loaders

Upvotes: 0

Tarsbir Singh
Tarsbir Singh

Reputation: 527

I faced this error:

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

Then I added the Design dependency in build.gradle - Module:app and it solved the problem:

implementation 'com.android.support:design:27.1.1'

Upvotes: 0

mkjorgensen
mkjorgensen

Reputation: 308

It seems Glide is using a newer version of a support library. You can either bump the rest of your support libraries to use the newest version as well, or if for other reasons you cannot do that, exclude the support library from the Glide library like this:

implementation ('com.github.bumptech.glide:glide:4.7.1', {
    exclude group: 'com.android.support'
})

annotationProcessor 'com.github.bumptech.glide:compiler:4.7.1'

Upvotes: 1

Hesham Morsy
Hesham Morsy

Reputation: 433

For your error for example :

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

*The solution is to compile the versions of these libraries like that :

implementation 'com.android.support:animated-vector-drawable:27.1.1'

-if another library had the same issue and had another version just compile it with your support:appcompat version

This resolved my problem and I hope it resolves yours.

Best wishes :)

Upvotes: 0

Arpan Sarkar
Arpan Sarkar

Reputation: 2406

Add this to your project level build.gradle file it will force all android support library to use the same version

allprojects {
    ...

    configurations.all {
        resolutionStrategy.eachDependency { details ->
            if (details.requested.group == 'com.android.support') {
                details.useVersion 'your library version here'
            }
        }
    }
}

Upvotes: 1

Reaz Murshed
Reaz Murshed

Reputation: 24251

You need to have a section defining the configuration to force a specific implementation of a library which needs to be used. For example,

configurations.all {
    resolutionStrategy {
        force 'com.android.support:design:25.3.1'
        force 'com.android.support:support-v4:25.3.1'
        force 'com.android.support:appcompat-v7:25.3.1'
    }
}

Upvotes: 0

Related Questions