Android Studio Gradle: Error:Execution failed for task ':app:processDebugGoogleServices'. > No matching client found for package

AndroidAndroid StudioAndroid Gradle-PluginGoogle Play-Servicesbuild.gradle

Android Problem Overview


I am trying to upgrade my google play services dependencies to 8.4.0 by following the example Google gives here, but I am getting the following error ('com.example.exampleapp' is a replacement for my app package name):

Error:Execution failed for task ':app:processDebugGoogleServices'.
> No matching client found for package name 'com.example.exampleapp'

Project build.gradle:

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

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

allprojects {
    repositories {
        jcenter()
    }
}

Module app/build.gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        applicationId "com.example.exampleapp"
        minSdkVersion 19
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    useLibrary 'org.apache.http.legacy'

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.android.support:cardview-v7:23.1.1'
    compile 'com.android.support:design:23.1.1'
    compile 'com.google.android.exoplayer:exoplayer:r1.5.2'
    compile 'com.google.android.gms:play-services-auth:8.4.0'
    compile 'com.google.android.gms:play-services-maps:8.4.0'
    compile('com.mapbox.mapboxsdk:mapbox-android-sdk:3.0.0@aar') {
        transitive = true
    }
    compile files('libs/commons-lang3-3.3.2.jar')
}

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

gradle-wrapper.properties:

#Fri Jan 01 08:23:56 CST 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.8-all.zip

Any ideas as to why gradle can't recognize my own app package name?


EDIT:

Ok, I'm getting different errors this time.

Based on the link Shawn Thye provided, I added this to the bottom of app/build.gradle:

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

and leaving everything else what I listed previously I got this error:

Information:Gradle tasks [clean, :app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:compileDebugSources, :app:compileDebugAndroidTestSources]
/Users/user/Documents/AndroidStudio/ExampleApp/app/build.gradle
Error:(1, 1) A problem occurred evaluating project ':app'.
> Failed to apply plugin [id 'com.android.application']
   > Gradle version 2.10 is required. Current version is 2.8. If using the gradle wrapper, try editing the distributionUrl in /Users/user/Documents/AndroidStudio/ExampleApp/gradle/wrapper/gradle-wrapper.properties to gradle-2.10-all.zip
Information:BUILD FAILED
Information:Total time: 0.921 secs
Information:1 error
Information:0 warnings
Information:See complete output in console

and the Gradle console:

Executing tasks: [clean, :app:generateDebugSources, :app:generateDebugAndroidTestSources]

Configuration on demand is an incubating feature.

FAILURE: Build failed with an exception.

* Where:
Build file '/Users/user/Documents/AndroidStudio/ExampleApp/app/build.gradle' line: 1

* What went wrong:
A problem occurred evaluating project ':app'.
> Failed to apply plugin [id 'com.android.application']
   > Gradle version 2.10 is required. Current version is 2.8. If using the gradle wrapper, try editing the distributionUrl in /Users/user/Documents/AndroidStudio/ExampleApp/gradle/wrapper/gradle-wrapper.properties to gradle-2.10-all.zip

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 1.211 secs

So, then I changed gradle-wrapper.properties as requested to "gradle-2.10-all" and got this error:

Information:Gradle tasks [clean, :app:generateDebugSources, :app:generateDebugAndroidTestSources]
google-services plugin could not detect any version for com.google.android.gms, default version: 8.3.0 will be used.
please apply google-services plugin at the bottom of the build file.
:clean
:app:clean
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72311Library
:app:prepareComAndroidSupportCardviewV72311Library
:app:prepareComAndroidSupportDesign2311Library
:app:prepareComAndroidSupportGridlayoutV72311Library
:app:prepareComAndroidSupportRecyclerviewV72311Library
:app:prepareComAndroidSupportSupportV42311Library
:app:prepareComDigitsSdkAndroidDigits192Library
:app:prepareComFacebookAndroidFacebookAndroidSdk470Library
:app:prepareComGoogleAndroidExoplayerExoplayerR152Library
:app:prepareComGoogleAndroidGmsPlayServicesAuth840Library
:app:prepareComGoogleAndroidGmsPlayServicesBase840Library
:app:prepareComGoogleAndroidGmsPlayServicesBasement840Library
:app:prepareComGoogleAndroidGmsPlayServicesMaps840Library
:app:prepareComGoogleAndroidGmsPlayServicesMeasurement830Library
:app:prepareComMapboxMapboxsdkMapboxAndroidSdk230Library
:app:prepareComTwitterSdkAndroidTweetComposer102Library
:app:prepareComTwitterSdkAndroidTweetUi180Library
:app:prepareComTwitterSdkAndroidTwitter1110Library
:app:prepareComTwitterSdkAndroidTwitterCore162Library
:app:prepareIoFabricSdkAndroidFabric1310Library
:app:prepareDebugDependencies
:app:compileDebugAidl
:app:compileDebugRenderscript
:app:generateDebugBuildConfig
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets
:app:processDebugManifest
:app:fabricGenerateResourcesDebug
:app:generateDebugResValues UP-TO-DATE
:app:processDebugGoogleServices
Found com.google.android.gms:play-services-auth:8.4.0, but version 8.3.0 is needed for the google-services plugin.
Found com.google.android.gms:play-services-maps:8.4.0, but version 8.3.0 is needed for the google-services plugin.
:app:processDebugGoogleServices FAILED
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 8.3.0.
Information:BUILD FAILED
Information:Total time: 5.724 secs
Information:1 error
Information:0 warnings
Information:See complete output in console

And the Gradle console:

Executing tasks: [clean, :app:generateDebugSources, :app:generateDebugAndroidTestSources]

Configuration on demand is an incubating feature.
google-services plugin could not detect any version for com.google.android.gms, default version: 8.3.0 will be used.
please apply google-services plugin at the bottom of the build file.
Incremental java compilation is an incubating feature.
:clean
:app:clean
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72311Library
:app:prepareComAndroidSupportCardviewV72311Library
:app:prepareComAndroidSupportDesign2311Library
:app:prepareComAndroidSupportGridlayoutV72311Library
:app:prepareComAndroidSupportRecyclerviewV72311Library
:app:prepareComAndroidSupportSupportV42311Library
:app:prepareComDigitsSdkAndroidDigits192Library
:app:prepareComFacebookAndroidFacebookAndroidSdk470Library
:app:prepareComGoogleAndroidExoplayerExoplayerR152Library
:app:prepareComGoogleAndroidGmsPlayServicesAuth840Library
:app:prepareComGoogleAndroidGmsPlayServicesBase840Library
:app:prepareComGoogleAndroidGmsPlayServicesBasement840Library
:app:prepareComGoogleAndroidGmsPlayServicesMaps840Library
:app:prepareComGoogleAndroidGmsPlayServicesMeasurement830Library
:app:prepareComMapboxMapboxsdkMapboxAndroidSdk230Library
:app:prepareComTwitterSdkAndroidTweetComposer102Library
:app:prepareComTwitterSdkAndroidTweetUi180Library
:app:prepareComTwitterSdkAndroidTwitter1110Library
:app:prepareComTwitterSdkAndroidTwitterCore162Library
:app:prepareIoFabricSdkAndroidFabric1310Library
:app:prepareDebugDependencies
:app:compileDebugAidl
:app:compileDebugRenderscript
:app:generateDebugBuildConfig
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets
:app:processDebugManifest
:app:fabricGenerateResourcesDebug
:app:generateDebugResValues UP-TO-DATE
:app:processDebugGoogleServices
Found com.google.android.gms:play-services-auth:8.4.0, but version 8.3.0 is needed for the google-services plugin.
Found com.google.android.gms:play-services-maps:8.4.0, but version 8.3.0 is needed for the google-services plugin.
:app:processDebugGoogleServices FAILED

FAILURE: Build failed with an exception.

* What went wrong:
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 8.3.0.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 5.724 secs

It's asking for the google-services plugin at the bottom of the build file, which it is already, and it's asking me to run 8.3.0 again... which I will do since that's the only thing working right now...

Android Solutions


Solution 1 - Android

"client": [
{
  "client_info": {
    "mobilesdk_app_id": "9:99999999:android:9ccdbb6c1ae659b8",
    "android_client_info": {
      "package_name": "[packagename]"
    }
  }

package_name must match what's in your manifest file. you can find the google-services.json file if you look in the example photo below.

enter image description here

Solution 2 - Android

Simple and easy. In my case it solved by as below

enter image description here

Make sure your pakage name in mainifests file same as your gradle's applicationId.

Solution 3 - Android

Happened to me when switching flavors.

Now you can also use the google-services.json with different flavors.

See https://stackoverflow.com/a/34364376/570168

Solution 4 - Android

Solved the problem of getting an exception

> java.lang.IllegalStateException: Default FirebaseApp is not > initialized in this process Make sure to call > FirebaseApp.initializeApp(Context) first.

in FirebaseInstanceId.getInstance().getToken()

Check that package_name exactly matches applicationId

  1. build.gradle

    defaultConfig { applicationId "build.gradle.exactly.matches.json" ... }


should exactly match 2) google-services.json

{
      "client_info": {
        "mobilesdk_app_id": "xxxxxxxxxxxxxxxxxxxxxxxxxx",
        "android_client_info": {
          "package_name": "build.gradle.exactly.matches.json"
        ....

Solution 5 - Android

This exact same error happened to me only when I tried to build my debug build type. The way I solved it was to change my google-services.json for my debug build type. My original field had a field called client_id and the value was android:com.example.exampleapp, and I just deleted the android: prefix and leave as com.example.exampleapp and after that my gradle build was successful.

Hope it helps!

EDIT

I've just added back the android: prefix in my google-services.json and it continued to work correctly. Not sure what happened exactly but I was able to solve my problem with the solution mentioned above.

Solution 6 - Android

For fixing:

> No matching client found for package name 'com.example.exampleapp:

You should get a valid google-service.json file for your package from here

For fixing:

> 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 8.3.0.:

You should move apply plugin: 'com.google.gms.google-services' to the end of your app gradle.build file. Something like this:

dependencies {
    ...
}
apply plugin: 'com.google.gms.google-services'

Solution 7 - Android

I meet the problem when using Firebase, i think different package cause the problem.

I solved by adding packeage of new app within Firebase Console, and download google-services.json again. enter image description here enter image description here enter image description here enter image description here

Solution 8 - Android

Open google-services.json in android studio we can see a json object, and contain following items in 'client' jsonarray

"client_id": "android:your package name", "package_name": "your package name",

Please verify your package and proceed.

Solution 9 - Android

I found success using this configuration:

classpath 'com.android.tools.build:gradle:1.5.0'
classpath 'com.google.gms:google-services:2.0.0-alpha3'
//or use
//classpath 'com.android.tools.build:gradle:2.0.0-alpha6'

and

distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip

using 8.40 Google Play services. Alpha5 & Alpha6 gave the same 2.8 error you had, regardless of the distributionUrl being 2.10

Solution 10 - Android

This happened to me when my package name wasn't represented in the google-services.json file I downloaded. Open your google-services.json file and make sure there is a client_info object that has a package name that corresponds to your manifests package name.

In googleservices.json:

"client": [
  {
    "client_info": {
    "mobilesdk_app_id": "my-app-id",
    "android_client_info": {
      "package_name": "com.me.android.test.myapp"
  }

and in your manifest:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.me.android.test.myapp" >

You may need to recreate a new google-services.json for your project, which you can create here: https://developers.google.com/mobile/add?platform=android&cntapi=gcm

Solution 11 - Android

your google-services.json package name must match your build.gradle applicationId (applicationId "your package name")

Solution 12 - Android

If this happened to you after renaming your application package name, then you need to update the following:

1)google-services.json file in your application by looking up in the file for "package_name" attribute and update it with the new package name.

2)Update your application client Credentials in Google Developers Console by going to the Credentials and selecting your android client key then update the package name as well with the new one.

Hope this will help.

Solution 13 - Android

check that, in your "google-services.json" file your package_name is available or not

Solution 14 - Android

i had the same problem and just easy solve it make sure the package name for package in mainfest tag inside manifest.xml file and the applicationId in application tag inside gradle app level file has the same package name

in manifest.xml

package="com.example.work"

in gradle app level

applicationId "com.example.work"

hope it help

Solution 15 - Android

1)check the package name is the same in google-services.json file

2)make sure that no other project exist with same package name

3)make sure that there is internet access

4)try syncing project and running it again

Solution 16 - Android

Add this in project gradle file

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

Solution 17 - Android

I think because your are using play-service 8.4.0

It required

classpath 'com.android.tools.build:gradle:2.0.0-alpha5'
classpath 'com.google.gms:google-services:2.0.0-alpha5'

you may also refer this.

Solution 18 - Android

For me, I had to check the google-services.json file and make sure "package_name" was correctly set to the package name of my android app. The auto generated services file had .backend appended to it in my case.

Solution 19 - Android

This happened to me when my package name wasn't represented in the google-services.json file I downloaded. Open your google-services.json file and make sure there is a client_info object that has a package name that corresponds to your manifests package name.

Make sure the package name in your project manifest is exactly the same in google-services.json file

thanks.

Solution 20 - Android

Just Android studio run 'Run as administrator' it will work

Or verify your package name on google-services.json file

Solution 21 - Android

after studying above that package name in manifest file and application id in gradle build file should be same. my issue didn't resolved.

Actually your application id in gradle build file should be same as your package name in google-services.json file. if your google-services.json file has different package name. delete that app from google analytics or firebase console. and get a new file.

Solution 22 - Android

Please verify build.gradle.

defaultConfig {
        applicationId "<packagename>"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }

Verify the package name.It can also cause error.

Solution 23 - Android

Both times when you write the package name :

  1. When you create a new project in Android Studio and
  2. When you create a Configuration File

YOU should write it with lowercase letters - after changing to lowercase it works. If you don't want to waste time just go to you .json file and replace com.myname.MyAPPlicationnamE with com.myname.myapplicationname (for every match in the json file).

Solution 24 - Android

if you run the other type of build(for example sign apk or etc), you must select app type of build then run the projects.

please seen the following image. for run this project we must select "app" in run configuration popup. enter image description here

Solution 25 - Android

In my case, I just had to do

  1. Click Build
  2. Click Make Project

It all then went fine. I still have no clue what happened.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionseanView Question on Stackoverflow
Solution 1 - Androidtech supportView Answer on Stackoverflow
Solution 2 - AndroidHirenView Answer on Stackoverflow
Solution 3 - AndroidTobiasView Answer on Stackoverflow
Solution 4 - AndroidAlex BurovView Answer on Stackoverflow
Solution 5 - AndroidcarotorrehdzView Answer on Stackoverflow
Solution 6 - AndroidepoolView Answer on Stackoverflow
Solution 7 - AndroidHenryChuangView Answer on Stackoverflow
Solution 8 - Androidsree_sgView Answer on Stackoverflow
Solution 9 - AndroidCole MurrayView Answer on Stackoverflow
Solution 10 - AndroidChrisView Answer on Stackoverflow
Solution 11 - AndroidlingyfhView Answer on Stackoverflow
Solution 12 - AndroidSami EltamawyView Answer on Stackoverflow
Solution 13 - AndroidAhamadullah SaikatView Answer on Stackoverflow
Solution 14 - AndroidAbdalrhman AlkhulaqiView Answer on Stackoverflow
Solution 15 - AndroidArya PrabagarView Answer on Stackoverflow
Solution 16 - AndroidMakvinView Answer on Stackoverflow
Solution 17 - AndroidShawn ThyeView Answer on Stackoverflow
Solution 18 - AndroidMicroView Answer on Stackoverflow
Solution 19 - AndroidTareqBallanView Answer on Stackoverflow
Solution 20 - AndroidMuhammed FasilView Answer on Stackoverflow
Solution 21 - AndroidDevelopineView Answer on Stackoverflow
Solution 22 - AndroidReju KoshyView Answer on Stackoverflow
Solution 23 - AndroidRares-Mihai ChelariuView Answer on Stackoverflow
Solution 24 - AndroidAli RasouliView Answer on Stackoverflow
Solution 25 - AndroidAbel CallejoView Answer on Stackoverflow