android studio error- mixing versions can lead to run-time crashes

17,630

Solution 1

The problem is that you use two (or more) different versions of the same dependency. The first one is specified in your gradle file and the other dependencies are used by library which you use (in this case firebase-ui probably).

You have more options here. At first you should try to update firebase-ui dependency. They usually keep their support dependecies updated so I guess that they use the same version of support libraries as you in their current master branch (I guess that you use the newest 'com.android.support:appcompat' version, right?). If the last version of firebase-auth doesn't use the current version of support libraries you can either downgrade your support libraries version so it will match their either you can create your own fork of firebase-auth and keep it updated on your own.

Solution 2

Here exist an error!

compile 'com.android.support:appcompat-v7:25.3.1'

All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 25.3.1, 25.3.0. Examples include 'com.android.support:animated-vector-drawable:25.3.0' and 'com.android.support:mediarouter-v7:24.0.0'

Seeing this Examples include 'com.android.support:animated-vector-drawable:25.3.0' and 'com.android.support:mediarouter-v7:24.0.0'

Just add these codes in dependencies, make sure that versions are same.

Just update build.gradle file with this :-

compile 'com.android.support:animated-vector-drawable:25.3.1'
compile 'com.android.support:mediarouter-v7:25.3.1'

Solution 3

What you need to do is check the which library dependency version is conflicting you can track that library with Run androidDependancies like: AndroidDependacies Report
and then find that conflicting dependency and add those dependencies with updated versions in your gradle file.

Solution 4

Add these lines of code in your build.gradle (Module:app) file at end:

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

You must change useVersion from '25.3.1' to your current compile/implementation SDK version.

NOTE:

If you are still using compile in your build.gradle file then replace it with implementation or api because compile support will be ended officially at the end of 2018.

For more details you may refer:

Error: when I replace compile with implementation in gradle(dependency)

What's the difference between implementation and compile in gradle

Share:
17,630
kaka
Author by

kaka

Updated on June 11, 2022

Comments

  • kaka
    kaka almost 2 years

    I get an error after adding 'com.firebaseui:firebase-ui-auth:1.0.0' to the dependency. The error goes away when I delete 'com.firebaseui:firebase-ui-auth:1.0.0' from the gradle. Code and pic included below Help please

    apply plugin: 'com.android.application'
    
    android {
    compileSdkVersion 25
    buildToolsVersion "25.0.2"
    defaultConfig {
        applicationId "com.example.a.chatapp"
        minSdkVersion 22
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    }
    
    dependencies {
    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'
    })
    compile 'com.android.support:appcompat-v7:25.3.0'
    
    
    
    compile 'com.firebaseui:firebase-ui:0.3.1'
    
    
    
    
    
    
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    testCompile 'junit:junit:4.12'
    }
    apply plugin: 'com.google.gms.google-services'
    

    enter image description here