No matching client found for package name (Google Analytics) - multiple productFlavors & buildTypes
Solution 1
Found this:
The google-services.json file is generally placed in the app/ directory, but as of version 2.0.0-alpha3 of the plugin support was added for build types, which would make the following directory structure valid:
app/src/ main/google-services.json dogfood/google-services.json mytype1/google-services.json ...
Solution 2
Check your package name on your google-services.json it should be same with your local package name of your app
Example
"client_info": {
"mobilesdk_app_id": "1:6596814400689:android:65d6f25f5006145",
"android_client_info": {
"package_name": "com.my.app.package.name"
}
In this case my local package name is com.my.app.package.name so also i have changed my package name in google-services.json with my local package name
Solution 3
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" //replace with the package_name in google-services.json =
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 applicationId
must be same.
Solution 4
I have found the solution:
We have to create two "apps" in the firebase project, and then we can download json file from any one app (I downloaded from the flavoured app). It will contain the data for both the apps. We can simply copy the json file to the app's root directory.
Source: https://firebase.googleblog.com/2016/08/organizing-your-firebase-enabled-android-app-builds.html
Solution 5
make sure your package name in "google-services.json" file is same with your apps's package name.
Viral Patel
Updated on July 08, 2022Comments
-
Viral Patel almost 2 years
Context:
I'm trying to set up Google Analytics for my app. (having 4 custom
buildTypes
and more than a fewproductFlavors
)It works fine when I select the
Build Variant
which has theapplicationId
set tocom.my.app.package.name
(the package name used when generating thegoogle-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 differentapplicationId
(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 custombuildType
andAllcategories
is one of myproductFlavors
.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 theapp
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:
- My custom
byildType
for debugging suffixes.debug
to theapplicationId
(package name). Is there a way I can make it work with thegoogle-services.json
which has my releaseapplicationId
(i.e. without the suffix.debug
) - 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 toapp
folder. I know it can be done usingtask
as mentioned in this post. Is there a simpler way to just have one file or pick right file based on gradle configuration? - I see the
package_name
field ingoogle-services.json
has the package namecom.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.
- My custom