update google services from 9.0.0 to 10.0.1 Androi

2019-07-11 05:28发布

问题:

I get an error saying

Error:Execution failed for task ':app:processDebugGoogleServices'.

Please fix the version conflict either by updating the version of the google-services plugin (information about the latest version is available at https://bintray.com/android/android-tools/com.google.gms.google-services/) or updating the version of com.google.android.gms to 9.0.0.

I tried looking at https://bintray.com/android/android-tools/com.google.gms.google-services/ and com.google.gms:google-services:3.0.0 seems to be the latest. This is my project gradle

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.3'
        classpath 'com.google.gms:google-services:3.0.0'


        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

And this is how my app gradle looks like

    apply plugin: 'com.android.application'


android {
    compileSdkVersion 23
    buildToolsVersion "23.0.1"
    defaultConfig {
        applicationId "sk.tipos.paradox02.citaj"
        minSdkVersion 11
        targetSdkVersion 23
        versionCode 27
        versionName '2.003'
    }


    buildTypes {
        release {
            minifyEnabled false
            multiDexEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
          //  signingConfig signingConfigs.release
        }

        debug {
            debuggable true
            minifyEnabled false
            multiDexEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt')
//            signingConfig signingConfigs.release
        }
    }


    productFlavors {
    }

    lintOptions {

        checkReleaseBuilds false

    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile 'com.google.gms:google-services:3.0.0'
    compile 'com.android.support:appcompat-v7:23.1.0'
    compile 'com.android.support:design:23.1.0'
    compile 'com.google.android.gms:play-services:10.2.0'
    compile 'com.google.android.gms:play-services-ads:10.2.0'
    compile 'com.google.android.gms:play-services-appindexing:9.8.0'
    compile 'com.google.android.gms:play-services-analytics:10.2.0'

    compile 'com.google.firebase:firebase-core:9.0.0'
    compile 'com.google.firebase:firebase-crash:10.0.1'
    compile 'com.google.firebase:firebase-ads:10.0.1'
    compile 'com.android.support:multidex:1.0.1'
}

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

If I change the play services to 9.0.0 everything compiles fine. What am I missing here?

Have you idea how resolve problem?

Thanks

回答1:

You are having this issue because Firebase was built using Google Play Services , so you can't use a version of Google Play Services higher than the version of Firebase.

Can you try :

   

apply plugin: 'com.android.application' android { compileSdkVersion 23 buildToolsVersion "23.0.1" defaultConfig { applicationId "sk.tipos.paradox02.citaj" minSdkVersion 11 targetSdkVersion 23 versionCode 27 versionName '2.003' } buildTypes { release { minifyEnabled false multiDexEnabled true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' // signingConfig signingConfigs.release } debug { debuggable true minifyEnabled false multiDexEnabled true proguardFiles getDefaultProguardFile('proguard-android.txt') // signingConfig signingConfigs.release } } productFlavors { } lintOptions { checkReleaseBuilds false } } dependencies { compile fileTree(include: ['*.jar'], dir: 'libs') testCompile 'junit:junit:4.12' compile 'com.google.gms:google-services:3.0.0' compile 'com.android.support:appcompat-v7:23.1.0' compile 'com.android.support:design:23.1.0' compile 'com.google.firebase:firebase-core:10.2.0' compile 'com.google.firebase:firebase-crash:10.2.0' compile 'com.google.firebase:firebase-ads:10.2.0' compile 'com.android.support:multidex:1.0.1' } apply plugin: 'com.google.gms.google-services'

Sorry for my english, hope it's help.



回答2:

Have you tried the solution given in this post: https://stackoverflow.com/a/37565535/3108709 . I had the same issue as you had, this solved it for me.

That's because you should always put the "apply plugin" clause at the bottom for google-services, since it looks for the already-added dependencies. Do it like this in your app-level gradle:

dependencies { compile 'com.google.android.gms:play-services-ads:9.0.1' } // ADD THIS AT THE BOTTOM apply plugin: 'com.google.gms.google-services'

This is hidden in the Firebase documentation, but applies even if you don't use Firebase.

Note : Update Google Repository also.



回答3:

You are using different versions of dependencies.Update their version to match version of latest google services version.

e.g.

compile 'com.google.android.gms:play-services:10.2.0'
compile 'com.google.android.gms:play-services-ads:10.2.0'
compile 'com.google.android.gms:play-services-appindexing:10.2.0'
compile 'com.google.android.gms:play-services-analytics:10.2.0'
compile 'com.google.firebase:firebase-core:10.2.0'
compile 'com.google.firebase:firebase-crash:10.2.0'
compile 'com.google.firebase:firebase-ads:10.2.0'