[android] Error: fix the version conflict (google-services plugin)

As per this SO thread, I know there are version conflicts, but issue still persists after new versions from Google.

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 10.0.1.

My build.gradle(Module: app)

....
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:26.+'
   compile 'com.android.support.constraint:constraint-layout:1.0.2'
   testCompile 'junit:junit:4.12'
   compile 'com.google.firebase:firebase-messaging:10.0.1'
   compile 'com.google.android.gms:play-services-maps:11.0.4'
   compile 'com.google.android.gms:play-services-location:11.0.4'
}

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


What changes are required now?

The answer is


install or update google play services. Secondly, check your 'com.google.gms:google-services:3.0.0' version . Check , this by upgrading it if still not work to 3.1.0


You must use only one version for all 3 libs

compile 'com.google.firebase:firebase-messaging:11.0.4'
compile 'com.google.android.gms:play-services-maps:11.0.4'
compile 'com.google.android.gms:play-services-location:11.0.4'

OR only use only 10.0.1 for 3 libs


With

com.android.tools.build:gradle:3.2.0

You have to use:

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

This fixed my problem


Please change your project-level build.gradle file in which you have to change your dependencies class path of google-services or build.gradle path.

buildscript {

    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.2'
        classpath 'com.google.gms:google-services:4.0.1'
    }
}

Important Update

Both Firebase & Play-service dependencies are having independent versions unlike past. If you have version conflicts then you can update your com.google.gms:google-services. and start defining independent version.

Step(1): Update com.google.gms:google-services

Open project level build.gradle and update com.google.gms:google-services to version 4.1.0 MUST CHECK newer if available.

buildscript {
    ...
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.0'
        classpath 'com.google.gms:google-services:4.1.0' //< update this 
    }
}

Step(2): Update Firebase dependencies Latest Versions

Firebase dependency versions can be individual.

com.google.firebase:firebase-core:16.0.3    //Analytics, check latest too
com.google.firebase:firebase-database:16.0.2    //Realtime Database, check latest too

Step(3): Update Play Services dependencies Latest Versions

Play services versions also can have individual versions.

com.google.android.gms:play-services-ads:17.1.2 //Ads, check latest too
com.google.android.gms:play-services-analytics:16.0.6   //Analytics, check latest too

Still having issue? You can check which dependency is making conflict by reading this answer.


Initially, the firebase database was pointing to 11.8.0 .after changing all the related jars to 11.0.4 this issue is resolved at changes the SDK level.

compile 'com.google.firebase:firebase-database:11.0.4'
compile 'com.google.firebase:firebase-messaging:11.0.4'

The google play services requires all its dependencies to have the same version. But if you look at your dependencies:

compile 'com.google.firebase:firebase-messaging:10.0.1'
compile 'com.google.android.gms:play-services-maps:11.0.4'
compile 'com.google.android.gms:play-services-location:11.0.4'

There is one that has a different version.

It can be solved by changing the version to (in this case) 11.0.4.

This applies to both Firebase and Google Play Services - both have to have matching versions that also correspond with each other. If a Firebase dependency is 10.0.1 and a Google Play Services dependency is 11.0.4, the same error will occur.

Note that in some cases, there can be a library that has a different version of a library (e.g. library x uses play-services-games:10.0.1 while you use 11.0.4 for the dependencies in your app)


Edit

This answer does NOT cover the newer versions where versions are individual. Update com.google.gms:google-services:4.1.0 and check mvnrepository (or some other maven/gradle artifact search tool) to find the newest versions.


For fire base to install properly all the versions of the fire base compiles must be in same version so

compile 'com.google.firebase:firebase-messaging:11.0.4' 
compile 'com.google.android.gms:play-services-maps:11.0.4' 
compile 'com.google.android.gms:play-services-location:11.0.4'

this is the correct way to do it.


as the message says go to: com.google.gms.google-services versions

And copy the last version's number . Mine was less than 3.3.1. Then in project's build.gradle put/change dependencies node as :

dependencies {
    classpath 'com.android.tools.build:gradle:3.1.2' // as it was before             
    classpath 'com.google.gms:google-services:3.3.1' // <-- the version change                  
        }

Then I synced the project and error went


After All Working for 6 hours i got the solution...

Simple Just what ever the plugins you defined in the build.gradle file... for ex: google services plugins or firebase plugins or any third party plugins all the **version code** should be same..

Example: In my application i am using following plugins...

    // google services plugins
    implementation 'com.google.android.gms:play-services-analytics:10.0.1'
    implementation 'com.google.android.gms:play-services-gcm:10.0.1'
    implementation 'com.google.android.gms:play-services-base:11.6.1'
    implementation 'com.google.android.gms:play-services-auth-api-phone:11.6.0'

    //firebase plugin
    implementation 'com.google.firebase:firebase-ads:10.0.1'

    //Third Party plugin
    implementation 'com.google.android.gms:play-services-auth:16.0.0'

In the above plugins version code(ex:10.0.1, 16.0.0, 11.6.1) are different I was facing fix the version conflict (google-services plugin) issue

Below for all plugins i have given single version code(11.6.0) and the issue is resovled...

 // google services plugins
    implementation 'com.google.android.gms:play-services-analytics:11.6.0'
    implementation 'com.google.android.gms:play-services-gcm:11.6.0'
    implementation 'com.google.android.gms:play-services-base:11.6.0'
    implementation 'com.google.android.gms:play-services-auth-api-phone:11.6.0'

    //firebase plugin
    implementation 'com.google.firebase:firebase-ads:11.6.0'

    //Third Party plugin
    implementation 'com.google.android.gms:play-services-auth:11.6.0'


**Syn Gradle**...

Go to Build>>Rebuild Projcet...

Sure it will work....@Ambilpura

All google services should be of same version, try matching every versions.

Correct one is :

  implementation 'com.google.firebase:firebase-auth:11.6.0'
  implementation 'com.google.firebase:firebase-database:11.6.0'

Incorrect Config is :

 implementation 'com.google.firebase:firebase-auth:11.6.0'
 implementation 'com.google.firebase:firebase-database:11.8.0'

Same error gets thrown when

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

is not added to bottom of the module build.gradle file.


Update google services and Firebase library to latest version

google services

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

firebase

 implementation 'com.google.firebase:firebase-database:19.0.0'

Examples related to android

Under what circumstances can I call findViewById with an Options Menu / Action Bar item? How to implement a simple scenario the OO way My eclipse won't open, i download the bundle pack it keeps saying error log getting " (1) no such column: _id10 " error java doesn't run if structure inside of onclick listener Cannot retrieve string(s) from preferences (settings) strange error in my Animation Drawable how to put image in a bundle and pass it to another activity FragmentActivity to Fragment A failure occurred while executing com.android.build.gradle.internal.tasks

Examples related to firebase

How can I solve the error 'TS2532: Object is possibly 'undefined'? Getting all documents from one collection in Firestore FirebaseInstanceIdService is deprecated Failed to resolve: com.google.firebase:firebase-core:16.0.1 NullInjectorError: No provider for AngularFirestore Firestore Getting documents id from collection How to update an "array of objects" with Firestore? firestore: PERMISSION_DENIED: Missing or insufficient permissions Cloud Firestore collection count iOS Swift - Get the Current Local Time and Date Timestamp

Examples related to google-play-services

com.google.android.gms:play-services-measurement-base is being requested by various other libraries Error: fix the version conflict (google-services plugin) Google Play Services GCM 9.2.0 asks to "update" back to 9.0.0 updating Google play services in Emulator How to unpublish an app in Google Play Developer Console Android Studio Gradle: Error:Execution failed for task ':app:processDebugGoogleServices'. > No matching client found for package Error "File google-services.json is missing from module root folder. The Google Services Plugin cannot function without it" com.android.build.transform.api.TransformException How to add google-services.json in Android? google-services.json for different productFlavors

Examples related to firebase-cloud-messaging

FirebaseInstanceIdService is deprecated Error: fix the version conflict (google-services plugin) How do you send a Firebase Notification to all devices via CURL? No notification sound when sending notification from firebase in android FCM getting MismatchSenderId Firebase (FCM) how to get token How to handle notification when app in background in Firebase What is FCM token in Firebase? Firebase FCM force onTokenRefresh() to be called Send push to Android by C# using FCM (Firebase Cloud Messaging)