ChatGPT解决这个技术问题 Extra ChatGPT

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?

Make sure version all play services is same.

V
Vadim Kotov

I think you change

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

So, only this was the issue! I wish I had tried it before posting :\
Make sure all Firebase SDK version is as same as play services version.
I was having the same kind of issue but all my version numbers were updated. After few minutes I discovered that it was giving error because I had put apply plugin: 'com.google.gms.google-services' at the bottom. As soon as I placed it at bottom it worked. Can someone explain me why it happened?
how to do this resolution on phonegap build
How to fix this in an Ionic/Cordova build?
C
CopsOnRoad

Same error gets thrown when

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

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


this worked for me, I just added it to the bottom of the file
Saved me! One has to wonder why Gradle smells so much like black magic though.
I wounder why setting plugin line on the top of Gradle will make an error and setting it at the bottom of file will work correct ??? Is there any one known the actual reason .
N
Nhaniso Undenge

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


amazing. Spent hours trying to figure out a build issue bc firebase was trying to use 17x and play-services-location was 16x. Thanks
Update, One can use individual versions stackoverflow.com/a/54593656/6891563
V
Vasily Kabunov

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'
    }
}

Z
Zoe stands with Ukraine

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.


Update, latest dependencies may have individual versions. stackoverflow.com/a/54593656/6891563
B
Blasco73

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


J
Joseph

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.


A
Adil Saiyad

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'

K
Khemraj Sharma

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.


P
Praveen

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'

C
CodeToLife

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


A
Abhishek Sengupta

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'

A
Ambilpura Sunil Kumar
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

A
Apurva Aggarwal

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


关注公众号,不定期副业成功案例分享
Follow WeChat

Success story sharing

Want to stay one step ahead of the latest teleworks?

Subscribe Now