No matching client found for package name (Google

2019-01-03 13:15发布

Context:

I'm trying to set up Google Analytics for my app. (having 4 custom buildTypes and more than a few productFlavors)

It works fine when I select the Build Variant which has the applicationId set to com.my.app.package.name (the package name used when generating the google-services.json). But, my other flavors have different applicationIds.

I followed the offical devguide to set it up.

Error I get when any another build variant is selected in Build Variants Tab (which has a different applicationId (package name) is as follows:

Error:Execution failed for task ':app:processAllcategoriesDebugfreeGoogleServices'.

No matching client found for package name 'com.my.app.package.name.debug'

Explanation of Error Message:

In the task name in the error message above Debugfree is my custom buildType and Allcategories is one of my productFlavors.

I understand the error and know the package name is different from what i used when generating the json, but that is what I'm trying to figure a way around.

Problem:

Now, the google-services.json resides in the app folder and hence I am not being able to separate them out for each product flavor by dropping them in the flavor specific source set folder.

Questions:

  1. My custom byildType for debugging suffixes .debug to the applicationId (package name). Is there a way I can make it work with the google-services.json which has my release applicationId (i.e. without the suffix .debug)
  2. Is there a way to have multiple product flavors configured in the same google-services.json file without using separate files and tasks to copy the required file to app folder. I know it can be done using task as mentioned in this post. Is there a simpler way to just have one file or pick right file based on gradle configuration?
  3. I see the package_name field in google-services.json has the package name com.my.app.package.name. Can I add multiple package names manually to work for all build variants? If yes, how to do that? Could not find any instructions in documentations.

26条回答
\"骚年 ilove
2楼-- · 2019-01-03 13:33

No matching client found for package name 'com.tf' I am pretty sure that The "package_name" in google-services.json is not matching with your "applicationId" in app gradle.

app gradle:

defaultConfig {
        applicationId "com.tf"
        minSdkVersion 23
        targetSdkVersion 26
        versionCode 7
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }

google-services.json

"client_info": {
        "mobilesdk_app_id": "1:23978655351:android:2b2fece6b961cc70",
        "android_client_info": {
          "package_name": "in.ac.geu.debug"
        }
      },

Solution: Just make sure the package_name and applicatoinId must be same.

查看更多
Root(大扎)
3楼-- · 2019-01-03 13:34

make sure your package name in "google-services.json" file is same with your apps's package name.

查看更多
一夜七次
4楼-- · 2019-01-03 13:35

I also get this issue when i change package name of my application.

In your android studio project find "google-services.json" file. Open it. and check whether package name of your application is same as written in this file.

The package name of your application and package name written in "google-services.json" file must be same.

查看更多
我欲成王,谁敢阻挡
5楼-- · 2019-01-03 13:36

Open your Google-services.json file and look for this section in the file:

"client": [
{
  "client_info": {
    "mobilesdk_app_id": "1:857242555489:android:46d8562d82407b11",
    "android_client_info": {
      "package_name": "com.example.duke_davis.project"
    }
  }

check whether the package is the same as your package name. Mine was different, so I changed it and it worked.

查看更多
走好不送
6楼-- · 2019-01-03 13:32
android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "com.package.name"
        minSdkVersion 19
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }

make sure Gradle.app's applicationId is same your package name. my problem was this and I solved this way

查看更多
爷的心禁止访问
7楼-- · 2019-01-03 13:37

I solved the same problem by re-syncing the file google-services.json.

Tools > Firebase > Connect to Firebase > Sync

查看更多
登录 后发表回答