135

I am following this link to integrate Google sign-in in my android app.https://developers.google.com/identity/sign-in/android/start-integrating As given in last step on the above given page we have to include dependency

 compile 'com.google.android.gms:play-services-auth:8.3.0' 

in app-level build.gradle file but doing so and building project an error comes saying

Error:Execution failed for task ':app:processDebugGoogleServices'.
> Please fix the version conflict.

build.gradle(Module:app)

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


android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        applicationId "com.brainbreaker.socialbuttons"
        minSdkVersion 16
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.0.1'
    compile 'com.android.support:design:23.0.1'
    compile 'com.google.android.gms:play-services-auth:8.3.0'
}

In the build.gradle file the compile dependency line compile 'com.google.android.gms:play-services-auth:8.3.0' shows error

All com.google.android.gms libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 8.3.0, 8.1.0. Examples include com.google.android.gms:play-services-base:8.3.0 and com.google.android.gms:play-services-measurement:8.1.0 There are some combinations of libraries, or tools and libraries, that are incompatible, or can lead to bugs. One such incompatibility is compiling with a version of the Android support libraries that is not the latest version (or in particular, a version lower than your targetSdkVersion.)

Here are the messages of gradle build.

Information:Gradle tasks [clean, :app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:compileDebugSources, :app:compileDebugAndroidTestSources, :social_buttons:generateDebugSources, :social_buttons:generateDebugAndroidTestSources, :social_buttons:compileDebugSources, :social_buttons:compileDebugAndroidTestSources]
:clean UP-TO-DATE
:app:clean
:social_buttons:clean
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72301Library
:app:prepareComAndroidSupportDesign2301Library
:app:prepareComAndroidSupportSupportV42301Library
:app:prepareComGoogleAndroidGmsPlayServicesAds810Library
:app:prepareComGoogleAndroidGmsPlayServicesAnalytics810Library
:app:prepareComGoogleAndroidGmsPlayServicesAppindexing810Library
:app:prepareComGoogleAndroidGmsPlayServicesAuth830Library
:app:prepareComGoogleAndroidGmsPlayServicesBase830Library
:app:prepareComGoogleAndroidGmsPlayServicesBasement830Library
:app:prepareComGoogleAndroidGmsPlayServicesMeasurement810Library
:app:prepareDebugDependencies
:app:compileDebugAidl
:app:compileDebugRenderscript
:app:generateDebugBuildConfig
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets
:app:generateDebugResValues UP-TO-DATE
:app:processDebugGoogleServices
Found com.google.android.gms:play-services-auth:8.3.0, but version 8.1.0 is needed
Found com.google.android.gms:play-services-auth:8.3.0, but version 8.1.0 is needed
Found com.google.android.gms:play-services-auth:8.3.0, but version 8.1.0 is needed
Found com.google.android.gms:play-services-auth:8.3.0, but version 8.1.0 is needed
Found com.google.android.gms:play-services-auth:8.3.0, but version 8.1.0 is needed
:app:processDebugGoogleServices FAILED
Error:Execution failed for task ':app:processDebugGoogleServices'.
> Please fix the version conflict.
Information:BUILD FAILED
Information:Total time: 3.49 secs
Information:1 error
Information:0 warnings
Information:See complete output in console

I am not able to see any way out for this version conflict. Any help is appreciated.

gautamprajapati
  • 2,055
  • 5
  • 16
  • 31

33 Answers33

375

I'v got a same issue. but Now I'm fixed.

You should delete a line apply plugin: 'com.google.gms.google-services'

because "com.android.application" package already has same package.

David Arenburg
  • 91,361
  • 17
  • 137
  • 196
seyeon
  • 4,092
  • 2
  • 15
  • 12
  • 27
    Then why do instructions on https://developers.google.com/analytics/devguides/collection/android/v4/ say to apply this plugin?? – IgorGanapolsky Feb 12 '16 at 17:49
  • 2
    You must apply the plugin at the end of the file. – Dielson Sales Mar 09 '16 at 14:26
  • Are you saying that ~"**com.android.application**" has same package as "**com.google.gms**"? – IgorGanapolsky Sep 01 '16 at 12:53
  • 1
    finally, all the answers had to do with adding the line, deleted it and it finally worked. – Ronen Sep 21 '16 at 11:31
  • I just found the "apply plugin: 'com.google.gms.google-services' line at the very start of my build.gradle in app when I had also added it again at the bottom -.- So now I have both com.android.application and also com.google.gms.google-services and it seems to be working so far. – Colibri Nov 16 '16 at 10:10
  • 1
    yes saved me.. but firebase implementation mention this.. any issues if we remove this? – Ranjithkumar Feb 21 '17 at 12:44
  • Actually i got an issue when delete the line `apply plugin: 'com.google.gms.google-services'` completely on Redmi HM Note 1W. It will always make my application force closed, while there is no problem on my other test phones, so i put it back at the end of the line and the problem gone! – HendraWD Mar 13 '17 at 07:41
  • 7
    If you have `com.google.gms:google-services:3.1.0` in your project-level gradle file, then delete the last line in app-level gradle: `apply plugin: 'com.google.gms.google-services`. If you have version 3.0.0 in project-level, leave the line untouched. Weird, but it works. – Sevastyan Savanyuk Aug 02 '17 at 08:06
  • 3
    NEVER DELETE apply plugin: 'com.google.gms.google-services' from the gradle. Sometimes you are using com.google.gms:google-services:3.1.0 , without apply plugin: 'com.google.gms.google-services' your gradle build successfully. BUT IT IS COMPLETELY WRONG !!!! – Zzmilanzz Zzmadubashazz Nov 24 '17 at 13:28
  • my app starts crashing on opening – San Daniel Feb 01 '19 at 05:19
  • 1
    those caused other exceptions : Execution failed for task ':app:fabricGenerateResourcesDebug'. – Nininea Feb 26 '19 at 14:52
  • Works for FLutter – TuGordoBello Jun 18 '20 at 05:45
  • 2
    This answer is totally wrong. It may do the trick, but then it will fail later on if you use any service that relies on google services. – Fran Marzoa Dec 24 '20 at 22:58
37

I had the same issue and resolved it by adding the following line in the dependencies of the project-level build.gradle:

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

For a full working example, check out the following project on github.

Hope this helps :)

Pankaj
  • 7,908
  • 6
  • 42
  • 65
TheYann
  • 1,367
  • 2
  • 12
  • 13
15

I was finding the same error complaining about mixing google play services version when switching from 8.3 to 8.4. Bizarrely I saw reference to the app-measurement lib which I wasn't using.

I thought maybe one of my app's dependencies was referencing the older version so I ran ./gradlew app:dependencies to find the offending library (non were).

But at the top of task output I found a error message saying that the google plugin could not be found and defaulting to google play services 8.3. I used the sample project @TheYann linked to compare. My setup was identical except I applied the apply plugin: 'com.google.gms.google-services' at the top my app's build.gradle file. I moved to bottom of the file and that fixed the gradle compile error.

scottyab
  • 23,621
  • 16
  • 94
  • 105
  • like its done here https://github.com/googlesamples/google-services/blob/master/android/signin/app/build.gradle – Jyotman Singh Jan 07 '16 at 10:44
  • I am using `compile 'com.google.android.gms:play-services-analytics:8.4.0'` and `compile 'com.google.android.gms:play-services-ads:8.4.0'`, and it still doesn't solve the issue. – IgorGanapolsky Feb 12 '16 at 17:36
  • 3
    @IgorGanapolsky have you moved apply plugin: 'com.google.gms.google-services' to bottom of app build.gradle? – Bin Feb 16 '16 at 10:47
  • 1
    About the strange reference to the app-measurement lib. This is actually automatically added by the Google Services Gradle plugin. If you look in the sources JAR downloaded, you'll notice one of the steps is to add a dependency to play-services-measurement. Interesting that they don't call this out in the docs -- it simply just says "Add dependencies for basic libraries required for the services you have enabled." [Doc Reference](https://developers.google.com/android/guides/google-services-plugin#introduction) – Android3000 Apr 05 '16 at 20:51
  • I'm having a very similar problem; My app utilizes Google Play Services Location 9.4.0 and a library I'm using (Outbound SDK) utilizes the base Google Play services but version 9.2.0. Is there anything I can do to avoid the conflict other than using 9.2.0 in my application and being forced to only upgrade Google Play Services when the library I'm dependent on updates their Google Play Services dependency? Any help is greatly appreciated! CC @IgorGanapolsky – Forrest Bice Sep 01 '16 at 04:12
  • Bloody voodoo sorcery!! I moved that line of code as you said, and the problem's gone. Thanks! – Josh Dec 18 '17 at 14:18
12

I also faced the same issue. But I forgot to add google-services.json in my project. You can get this file from Google.

Thirumalvalavan
  • 2,660
  • 1
  • 30
  • 32
12

Ensure that you have done these two things under defaultConfig in Android/app/build.gradle after wiring up Firebase for your Flutter app.

1) Whatever package name you entered while creating your Firebase android project, exactly the same should be updated as your applicationId under defaultConfig.

2) Add the line multiDexEnabled true under defaultConfig.

So defaultConfig{} should now look something like this

defaultConfig {
    applicationId "com.companyName.appName"
    minSdkVersion 16
    targetSdkVersion 27
    multiDexEnabled true
    versionCode flutterVersionCode.toInteger()
    versionName flutterVersionName
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
Sunit Gautam
  • 5,495
  • 2
  • 18
  • 31
4

I've solved this problem by deleting the google-services.json file and downloading it again from Firebase console.

Marie Amida
  • 556
  • 1
  • 5
  • 14
2

Had the same problem i added compile 'com.google.android.gms:play-services-measurement:8.4.0' and deleted apply plugin: 'com.google.gms.google-services' I was using classpath 'com.google.gms:google-services:2.0.0-alpha6' in the build project.

David Arenburg
  • 91,361
  • 17
  • 137
  • 196
Mwongera808
  • 880
  • 11
  • 16
2

In my case when i was using firebase services the google.json file was mismatched check once that also

Kamal
  • 245
  • 2
  • 3
2

Important note: You should only apply plugin at bottom of build.gradle (App level)

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

I mistakenly apply this plugin at top of the build.gradle. So I get error.

One more tips : You no need to remove even you use the 3.1.0 or above. Because google not officially announced

   classpath 'com.google.gms:google-services:3.1.0' 
Ranjithkumar
  • 16,071
  • 12
  • 120
  • 159
2

I just had to delete and reinstall my google-services.json and then restart Android Studio.

Foster
  • 136
  • 1
  • 8
2

If you trying to connect to firebase, check if your app package name is the same as what is in google-services JSON file.

"client": [
{
  "client_info": {
    "mobilesdk_app_id": "......",
    "android_client_info": {
      "package_name": "com.something.package"
    }
  }, ...

thanks and good luck.

1

had the same issue as described by @scottyab.

all references were 8.4.0 but it failed due to a reference to app-measurement 8.3.0 that i did not reference anywhere (but one of the dependencies?). you can see the problem if you hover over the bad(red) dependency in Android Studio. explicitly adding

compile 'com.google.android.gms:play-services-measurement:8.4.0'

to app.gradle solved the issue.

jogo
  • 12,469
  • 11
  • 37
  • 42
Philipp
  • 433
  • 3
  • 14
1

Also please check your package name in Manifest and package name in google services json file. If both have package name differ from one another u will have this issue.

1

I fixed it without deleting apply plugin: 'com.google.gms.google-services' I had the error Execution failed for task ':app:processDebugGoogleServices' because I was using two different versions of google services in my dependencies :

implementation "com.google.android.gms:play-services-maps:11.8.0"
implementation "com.google.android.gms:play-services-nearby:16.0.0"

I changed it to :

implementation "com.google.android.gms:play-services-maps:11.8.0"
implementation "com.google.android.gms:play-services-nearby:11.8.0"

Then it worked

Jack'
  • 1,722
  • 1
  • 19
  • 27
1

When you create an android application in firebase console you should set your application package in future it will be recorded to google-services.json. So this error can happen when you try to add google services in the application which has a different package (Current application package will not match to which was recorded to google-services.json).

Onregs
  • 420
  • 3
  • 16
1

My package name, when creating an application in Firebase, had an underscore '_' in the name.

I mistakenly excluded the underscore. Changing the package name in firebase solved this issue for me.

Jacob Zinn
  • 41
  • 2
1

I ran into the same issue, I followed the top three steps in this thread. However, I later found that package_name should match with appID in the google-service.json file as well.

Do look at what your package_name says in google.service.json and match it with the actual app id.

Manish
  • 11
  • 1
1

If You are trying to solve this problem for firebase then use this....

Deleting the ** 'com.google.gms.google-services' ** is not the correct way, this problem occurs because of the name changes.

Need to give the same name in the format firebase package name == android package name (check it in /android/app/src/main/AndroidManifest.xml)

Just change the name as android package name then again download the google-services.json then paste it in the /android/app/ like this (/android/app/google-services.json) and run your npm eg. npx react-native run-android It will work 100%.

Ramakay
  • 2,919
  • 1
  • 5
  • 21
  • But applicationId and local package name are independent. Changing applicationId should also work, I think. – highjump Apr 17 '22 at 21:22
0

I had a similar issue/error.. fixed it by moving apply plugin: 'com.google.gms.google-services'
to the end of app level gradle file.

And updated the version of gms:play-services and gms:play-services auth

Kanishk Gupta
  • 369
  • 2
  • 10
0

same issue i have.

i tired all possible solutions that i found. but non were worked.

always got this error

Cannot add task ':processDebugGoogleServices' as a task with that name already exists

Now, i solved it.

1) first i checked my config.xml

2) and removed unnecessary plugin. (I used firebase fcm plugin for pushnotification, but there was two unnecessary plugin phonegap-plugin-push and cordova-plugin-customurlscheme. I removed both these plugins)

3) then removed platform.

4) then add platform

5) then build it.

6) now it build successfully.

Harish Mahajan
  • 3,254
  • 4
  • 27
  • 49
0

Had the same problem with malformed error Deleted the line apply plugin: 'com.google.gms.google-services' And the build got successful

Haris Durrani
  • 119
  • 1
  • 9
0

NEVER DELETE apply plugin: 'com.google.gms.google-services' from the gradle. Sometimes you are using com.google.gms:google-services:3.1.0 , without apply plugin: 'com.google.gms.google-services' your gradle build successfully. BUT IT IS COMPLETELY WRONG !!!! This error comes due to google-service.json file is not at the correct location. Go to your PROJECT TAB at left side above. If you display it as ANDROID make it PROJECT then check your google-service.json file is at this location. EXPAND app then see google-service.json file below the build.gradle. IF NOT PLACE IT THERE BY RIGHT CLICK ON THE app .

0

This error comes up when there is change in your config.xml file resulting in mismatching of the data present in google-services.json file. I got it fixed this just by updating changes to my google-services.json file and building the app again ...it worked well.

0

If you´re building a new app, put the jsonfile in the right place and make sure it's the jsonfile for that app. Before I realized this, when I clicked the jsonfile, I didn't get the information that wanted.

Go to firebase configurations, download the correct version of google-services.json, and replace the version that didn't work for you. When using the wrong version, you might see the wrong Projectid, storagebucket etc.

DSlomer64
  • 4,234
  • 4
  • 53
  • 88
HappyG
  • 1
0

check gradle.properties and add android.useAndroidX=true or you can also add android.enableJetifier=true or you can comment it by #

worked for me

Ramesh
  • 21
  • 6
0

if you got an error

Execution failed for task ‘:app:fabricGenerateResourcesDebug’. Crashlytics Developer Tools error.

remove also this line:

apply plugin: 'io.fabric'
Adam Smaka
  • 5,977
  • 3
  • 50
  • 55
0

In my case i have multiple product flavors. It used to work earlier. It stopped working after updating project gradle version to 4.0.1 and 'google-services:4.3.4'.

I got error like 'Task :app:processDebugGoogleServices FAILED' when i run the project.

I replaced 'google-services.json' in app module with 'my-product-flavor/google-services.json'. It is working fine now.

Rahul
  • 481
  • 4
  • 9
0

None of the answers here helped. I needed to have "apply plugin: 'com.google.gms.google-services'" in my gradle. What helped was updating Android Studio to the latest version. I was then able to add the plugin and connect to Firebase Messaging Service.

user3079872
  • 191
  • 1
  • 5
  • 15
  • If your package name is correct, try updating to this version (for Android Studio Chipmunk with Gradle plugin 7.2.1): `com.google.gms:google-services:4.3.13` – Andy H. Jul 04 '22 at 15:11
0

What work for me is

add this in build.Gradle(Project)

dependencies {

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

      }
Sam
  • 241
  • 3
  • 7
0

Try adding FirebaseAuth even though you don't need it. Don't delete any plugins. This worked for me. Thanks.

Vicky
  • 71
  • 1
  • 2
0

First, check your package name(eg. com.itfosters.****) in the File(build.gradle) file and APP_FOLDER\android\app google-services.son(Downloaded file from Google firebase).

If mismatched please correct that. Then use this common

flutter clean;
flutter pub get;

Thanks

0

In my case this problem happens after I changed the app name and package name, I noticed that applicationId "" was empty so I added the new package name to it

android {
    compileSdk 33

    defaultConfig {
        applicationId "com.test.new.package.name"
        minSdk 21
        targetSdk 33
        versionCode 1
        versionName "1.0"
        multiDexEnabled true

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
Dr Mido
  • 2,414
  • 4
  • 32
  • 72
-3

I'v got a same issue. but Now I'm fixed.

You should delete a line apply plugin: 'com.google.gms.google-services'

because "com.android.application" package already has same package.

maharsh
  • 39
  • 1
  • 1
  • 3