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:
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
)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?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.The package name of an Android app uniquely identifies your app on the device, in Google Play Store, and in supported third-party Android stores.
The google-services. json file is generally placed in the app/ directory (at the root of the Android Studio app module).
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
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 ...
Source
Source 2
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With