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:
- 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.
Found this:
Source
Source 2
I think you have added firebase json file "google-services".json with the new file. Make sure to create a new file check the link on how to create json file from firebase and it should match with your package name
Second thing is that if you are changing the package name use the option " replace in path" when you right click under files when you select project from the drop down. You have to search for package name in the whole project and replace it !
Hope this helps !