gentra gentra - 1 year ago 1146
Android Question

google-services.json for different productFlavors

I'm implementing the new Google Cloud Messaging following the guides from the Google Developers page here

I've successfully run and test it. But my problem now is I have different productFlavors with different applicationId/packageName and different GCM Project Id. The

have to be put at the
not the flavors folder.

Is there any way to make the
config different for many flavors?

Answer Source

Google just included support for flavors on version 2.0 of the play services plugin. Since this version of the gradle plugin

you can do this


Version 3.0.0 of the plugin will search for the json file in these locations for flavor1:


This worked for me even using flavorDimensions. I have free & paid in one dimension and Mock & Prod in the other dimension. I also have 3 buildTypes: debug, release and staging. This is how it looks in my project for the FreeProd flavor:

enter image description here

If you want more details about what this plugin does with these json files, here it is:

Link to the official docs:

And go here to check the latest version of this plugin:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download