Oussama
Oussama

Reputation: 633

How to fix mixed version in android build.gradle? (libraries must use the exact same version)

I have a problem in gradle configuration, I get this error

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

https://image.ibb.co/gwJ16n/Untitled.png "error"

How do I fix this problem?

Here is the complete buil.gradle configuration.

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "com.sakan"
        minSdkVersion 15
        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.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.0'
    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 'com.android.support:design:27.1.1'
    implementation 'com.android.support:cardview-v7:27.1.1'
    implementation 'com.android.support:recyclerview-v7:27.1.1'
    implementation 'com.github.linger1216:labelview:v1.1.1'
    implementation 'com.github.ViksaaSkool:AwesomeSplash:v1.0.0'
    implementation 'com.nineoldandroids:library:2.4.0'
    implementation 'com.daimajia.easing:library:1.0.1@aar'
    implementation 'com.daimajia.androidanimations:library:1.1.3@aar'
    implementation 'com.android.support:multidex:1.0.3'
    implementation 'com.google.android.gms:play-services-maps:15.0.0'
    implementation 'com.google.android.gms:play-services-location:15.0.0'
    implementation 'com.facebook.android:facebook-android-sdk:4.32.0'
    implementation group:'com.squareup.picasso', name:'picasso', version:'2.5.0'
    implementation 'com.github.chenupt.android:springindicator:1.0.2@aar'
    implementation 'me.relex:circleindicator:1.2.2@aar'
    implementation 'com.txusballesteros:bubbles:1.2.1'
    implementation 'com.romainpiel.shimmer:library:1.4.0@aar'
    implementation 'tyrantgit:explosionfield:1.0.1'
    implementation 'com.github.ksoichiro:android-observablescrollview:1.5.0'
    implementation 'com.nineoldandroids:library:2.4.0'
    implementation 'com.github.bumptech.glide:glide:3.7.0'
    implementation 'com.google.android.gms:play-services-auth:15.0.0'
    implementation 'com.jakewharton:butterknife:7.0.1'
    implementation 'com.mcxiaoke.volley:library-aar:1.0.0'
    implementation 'com.loopj.android:android-async-http:1.4.9'
    implementation 'com.github.darsh2:MultipleImageSelect:v0.0.4'
    implementation 'com.facebook.android:facebook-android-sdk:4.32.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.0'
    implementation 'com.google.firebase:firebase-appindexing:15.0.0'
    implementation 'com.github.manuelpeinado.fadingactionbar:fadingactionbar:3.1.2'
    implementation 'com.github.manuelpeinado.fadingactionbar:fadingactionbar-abc:3.1.2'
}

I think one of the dependencies is using a different target version, I don't know how to fix this problem.

Upvotes: 1

Views: 834

Answers (3)

Oussama
Oussama

Reputation: 633

Add this to the very end of your build.gradle (Module:app):

configurations.all {
    resolutionStrategy.eachDependency { details ->
        def requested = details.requested
        if (requested.group == 'com.android.support') {
            if (!requested.name.startsWith("multidex")) {
                details.useVersion '27.1.1'
            }
        }

    }
}

Make sure that you replace '27.1.1' with the version of the android support library that you want to use for all the dependencies , it should not be lower than your complile sdk version

than re sync gradle

I found this answer in : here

Upvotes: 2

Dhaval Patel
Dhaval Patel

Reputation: 330

try to change config in build.gradle, as below

configurations.all {

    resolutionStrategy {
        force 'com.android.support:design:27.0.2'
        force 'com.android.support:support-v4:27.0.2'
        force 'com.android.support:appcompat-v7:27.0.2'
    }
}

It makes forcefull changed to stated version, sometimes this is needed for signed apks

EDIT 1: The error which is shown in image, won't bother builiding apk.

The error here is of aapt2. By default aapt2 is enabled from gradle version 3.0+, you need to disable it by adding android.enableAapt2=false to gradle.properties file.

If it doesn't work, look for solution for aapt2 errors.

I have run build apk with above, by forcing support version as above, works fine for me, although error line didn't disappear

Upvotes: 1

sp...
sp...

Reputation: 61

Change build.gradle to -> dependencies {

implementation 'com.android.support:appcompat-v7:27.1.1'

implementation 'com.android.support.constraint:constraint-layout:1.1.0'

}

Upvotes: 0

Related Questions