4

For our app I am using two different firebase projects:

  • Live: Contains the live iOS & Android app
  • Test: Contains all our iOS & Android testing apps

As far as I could see the google-services.json (Android) contains the firebase project information and all related apps (as "client"). Is it supported to add a second "project_info" into this file?

Fahim
  • 1,431
  • 1
  • 15
  • 28
  • Why do you need to add two projects into the services.json file ? use case? – OBX Feb 07 '17 at 09:18
  • We have 3 different testing apps and one production app. If the app marketing manager wants to send a notification, he or she always has to choose the production app out of 4 apps... that results to a really bad user experience in the firebase console. – Fahim Feb 07 '17 at 09:31

1 Answers1

10

Why don't you try android application flavors, for that Google just included support for flavors on version 2.0 of the play services plugin. Since this version of the gradle plugin com.google.gms:google-services:2.0.0-alpha3

you can do this

app/src/ flavor1/google-services.json flavor2/google-services.json Version 3.0.0 of the plugin will search for the json file in these locations (considering you have a flavor flavor1 and a build type debug):

/app/src/flavor1/google-services.json
/app/src/flavor1/debug/google-services.json
/app/src/debug/google-services.json
/app/src/debug/flavor1/google-services.json
/app/google-services.json

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.

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: https://github.com/googlesamples/google-services/issues/54#issuecomment-165824720

Link to the official docs: https://developers.google.com/android/guides/google-services-plugin

And go here to check the latest version of this plugin: https://bintray.com/android/android-tools/com.google.gms.google-services/view

crusy
  • 1,424
  • 2
  • 25
  • 54
Himeshgiri gosvami
  • 2,559
  • 4
  • 16
  • 28
  • Thanks Himesh! I was not aware that google-services supports build types & flavors – Fahim Feb 07 '17 at 09:42
  • One hint for the community: this works also for other files such as Java files. They are merged together by the Gradle build. – Fahim Feb 08 '17 at 23:01