When you include google-services.json
in your project, the information in that file is baked into your APK at compile time by the google-services
gradle plugin.
But you can also initialize the FirebaseApp
instance with values you provide directly in your code. See the example in my answer here: How to connect to more than one firebase database from an android App or this section of the Firebase documentation:
// Manually configure Firebase Options
FirebaseOptions options = new FirebaseOptions.Builder()
.setApplicationId("1:27992087142:android:ce3b6448250083d1") // Required for Analytics.
.setApiKey("AIzaSyADUe90ULnQDuGShD9W23RDP0xmeDc6Mvw") // Required for Auth.
.setDatabaseUrl("https://myproject.firebaseio.com") // Required for RTDB.
.build();
FirebaseApp app = FirebaseApp.initializeApp(getApplicationContext(), options);
FirebaseDatabase database = FirebaseDatabase.getInstance(app);
Just ignore the mentions of "multiple projects" in the links - while that is the more common reason for needing this code, it will also work for your need.