I have multiple flavors of my app. How should I set this up server side? My package names are:
com.example.app (production)
com.example.app.stagin
Note I didn't fully try this yet, but documenting it here to not lose it until I get to it.
One actually isn't forced to use the gradle plugin, which enforces you to have a firebase project for all of your flavors and build types.
This is poorly documented, but one can find a hint at the top of the documentation for FirebaseApp and some more at https://firebase.google.com/docs/configure/
Alternatively initializeApp(Context, FirebaseOptions) initializes the default app instance. This method should be invoked from Application. This is also necessary if it is used outside of the application's main process.
So, fetch the google-services.json as usual and from it take mobilesdk_app_id and current_key (under api_key), that should be all that's needed for Google Analytics tracking at least. With that information run the following in your app's Application subclass for the variants where you need it:
FirebaseOptions options = new FirebaseOptions.Builder()
.setProjectId("")
.setApplicationId("")
.setApiKey("")
.build();
FirebaseApp.initializeApp(this, options);