All gms/firebase libraries must use the exact same

2019-08-25 10:21发布

问题:

While tring to update 'com.google.firebase:firebase-crash:10.2.0' to 'com.google.firebase:firebase-crash:11.8.0' I am getting this error

All gms/firebase libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 11.8.0, 10.2.0. Examples include com.google.android.gms:play-services-basement:11.8.0 and com.google.android.gms:play-services-base:10.2.0

How can I solve this error?

app build.gradle

apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
apply plugin: 'com.google.firebase.firebase-crash'

repositories {
    mavenCentral()
    maven {
        url "https://oss.sonatype.org/content/repositories/ksoap2-android-releases/"
    }
    maven { url 'https://maven.fabric.io/public' }
}

android {
    compileSdkVersion 27
    buildToolsVersion "27.0.3"
    dexOptions {
        jumboMode = true
    }
    defaultConfig {
        applicationId "com.myapp.myapp"
        minSdkVersion 16
        multiDexEnabled true
        targetSdkVersion 27
        versionCode 6
        versionName '1.1'

        ndk {
            abiFilters "armeabi-v7a", "x86"
        }

    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        debug {
            debuggable true
        }
    }
    productFlavors {
    }
//    configurations {
//        all*.exclude group: 'org.apache.commons'
//    }

}

repositories {
    mavenCentral()
}

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

    }
}


dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile project(':platform')
    compile project(':ahbottomnavigation')
    compile project(':mylibrary')
    compile('com.crashlytics.sdk.android:crashlytics:2.6.7@aar') {
        transitive = true
    }
    compile('com.google.android.gms:play-services-cast-framework:10.2.0') {
        exclude group: 'com.android.support', module: 'mediarouter-v7'
    }
    compile project(':bottom-bar')
    compile project(':journey')
    compile "com.android.support:appcompat-v7:$rootProject.ext.supportLibraryVersion"
    compile "com.android.support:recyclerview-v7:$rootProject.ext.supportLibraryVersion"
    compile 'com.google.firebase:firebase-crash:11.8.0'
    compile 'com.github.rahatarmanahmed:circularprogressview:2.5.0'
    compile 'com.flurry.android:analytics:6.9.0'
    compile "com.android.support:mediarouter-v7:$rootProject.ext.supportLibraryVersion"
    compile 'com.googlecode.android-query:android-query:0.25.9'
    compile 'com.github.hotchemi:android-rate:1.0.1'
    compile "com.android.support:cardview-v7:$rootProject.ext.supportLibraryVersion"
    compile "com.android.support:support-v4:$rootProject.ext.supportLibraryVersion"
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'com.facebook.android:facebook-login:4.31.0'
    testCompile 'junit:junit:4.12'
}

apply plugin: 'com.google.gms.google-services'

$rootProject.ext.supportLibraryVersion=='27.1.0'

回答1:

I have no idea how your build.gradle for sub-projects look like, they should have same version as your app build.gradle, if you used any of com.google. libs inside the sub-projects.

However your compile('com.google.android.gms:play-services-cast-framework:10.2.0') should have the same version 11.8.0



回答2:

You need to change the following dependency to 11.8.0:

compile('com.google.android.gms:play-services-cast-framework:10.2.0') {
    exclude group: 'com.android.support', module: 'mediarouter-v7'
}

because firebase-crash using 11.8.0

compile 'com.google.firebase:firebase-crash:11.8.0'


回答3:

All the google gms dependencies and firebase dependencies must have the same version number. For eg. in your case, you are using 11.8.0 for Firebase but 10.2.0 for 'com.google.android.gms:play-services-cast-framework:10.2.0'



回答4:

Firstly, the versions of google play services and firebase you are referring to are quite old. Now, see the following:

Google Play Service - latest set of libraries

Firebase - latest set of libraries

Secondly, once you upgrade, you might find that you can't get the same version of all the libraries, and that is by design. Google now uses a new versioning system, as written in their May 2018 blog post announcing new SDK versioning. So it is no longer appropriate to use all the same version number. According to google, upgrade to Android Studio 3.1 to stop getting that warning.