Google Play Services GCM 10.0.1 asks to “update” b

2019-02-17 06:33发布

问题:

I'm trying to build my new project, but I get this error:

Error:Execution failed for task ':mobile: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.

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

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.1"
    defaultConfig {
        applicationId "com.julia.android.example_project"
        minSdkVersion 10
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    buildTypes.each {
        it.buildConfigField 'String', 'API_KEY', myKey
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:25.0.1'
    ...
    compile 'com.google.android.gms:play-services:10.0.1'
    compile 'com.google.android.gms:play-services-gcm:10.0.1'
    compile 'com.google.android.gms:play-services-location:10.0.1'
    wearApp project(':wear')
}

And

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

allprojects {
    repositories {
        jcenter()
    }
}

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

I tried to move apply plugin: 'com.google.gms.google-services' at the bottom of my app/build.gradle file, but it didn't work out.

Any ideas, please?

回答1:

Had this issue earlier today. Just apply the google services plugin before you apply the android application plugin.

Update the following lines:

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

to:

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


回答2:

I had the same issue, I solved it looking for all the "build.grade" files in the project to change all the versions from 9.8.0 to 10.0.1 (you can do a search "find in path" to search the 9.8.0 string), I had one missing and this caused the error.

And also the line:

compile 'com.google.android.gms:play-services-appindexing:9.8.0'

must be replaced by:

compile 'com.google.firebase:firebase-appindexing:10.0.1'


回答3:

To fix this you have to do the following.

First, even if the documentation says "Add this"

 dependencies {
        compile 'com.google.android.gms:play-services:10.0.1'
 }

Don't do it, because that is the whole google play services API, since version 6.5 if I remember correctly google play services is a selective API, it means that you must include only what you need.

Read this page entirely until you read Selectively compiling APIs into your executable.

Second, check that all your version numbers are the same, you can't mix them; check the link before, and choose only what you need.

By the way the class path is

classpath 'com.google.gms:google-services:3.0.0'

Not beta-1 as @JuliaKo said.

P.S. If you speak Spanish, read my post about this here



回答4:

In my case, check that not only google-play-services, but firebase services are of the same version as well.



回答5:

Put this line after dependencies closure at the bottom:

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


回答6:

I solved this problem replacing this classpath 'com.google.gms:google-services:3.0.0' to this classpath 'com.google.gms:google-services:1.3.0-beta1'



回答7:

According to my own experience, you have to set that version to all the gms google services plugins. So, in your case you should replace

compile 'com.google.android.gms:play-services:10.0.1' compile 'com.google.android.gms:play-services-gcm:10.0.1' compile 'com.google.android.gms:play-services-location:10.0.1' for

compile 'com.google.android.gms:play-services:9.0.0'
compile 'com.google.android.gms:play-services-gcm:9.0.0'
compile 'com.google.android.gms:play-services-location:9.0.0'

Besides, as other users have suggested, you have to add

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

at the bottom of the app.module graddle file