Skip to content Skip to sidebar Skip to footer

Add Multiple Google-service.json File In Product Flavor

I have 3 different Firebase projects. and it has to be used in 4 google-service.json use in product flavors. but i get an below error File google-services.json is missing. The Go

Solution 1:

Answer :

The only way I was able to do this was to bypass use of google-services.json and create FirebaseApp instance dynamically e.g.

if (<is dev>) {
        apiKey = <dev api key>;
        databaseUrl = <dev database url>;
    } elseif (<is test> {
        apiKey = <>;
        databaseUrl = <>;
    } else// production {
        apiKey = <>;
        databaseUrl = <>;
    }


    FirebaseOptions firebaseOptions = new FirebaseOptions.Builder()
            .setApiKey(apiKey)
            .setApplicationId(context.getString(R.string.google_app_id))
            .setDatabaseUrl(databaseUrl)
            .build();

    return FirebaseApp.initializeApp(context, firebaseOptions, "MyApp");

Post a Comment for "Add Multiple Google-service.json File In Product Flavor"