google-services.json for different productFlavors

The Solution to google-services.json for different productFlavors is

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

you can do this

Step 1: add to gradle

// To auto-generate google map api key of google-services.json
implementation ''

Step 2: add to AndroidManifest.xml in application tag

    android:value="@string/google_api_key" />

Step 3: download each flavor JSON file from firebase and add it


Version 3.0.0 of the plugin searches for the json file in these locations (considering you have a flavor flavor1 and a build type debug):


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

How many google-services.json files will depend on your project's characteristics, but you will need at least one json file for every Google project.

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

Link to the official docs:

Blog post with updated info:

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

~ Answered on 2015-12-18 21:42:30

Most Viewed Questions: