Here we are working on the project that uses the Firebase Realtime Database. Is it possible to make different Firebase Database for Release and Debug mode in single Android app?
Project:(App with release/debug mode)
What is the best idea to solve this Test/Production environment for Firebase Database?
Create multiple Realtime Database instancesIn the Firebase console, go to the Data tab in the Develop > Database section. Select Create new database from the menu in the Realtime Database section. Customize your Database reference and Security rules, then click Got it.
You're limited to one database per project. You'll need multiple projects to get multiple db instances. You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
Yes, You can use the same firebase database in more than one android application as below: In the Project Overview section of Firebase Console add an android application.
There is only a single database in a project at the moment. So either you'll need to model debug and release data into the same database or you'll need a separate project for each.
Many of these scenarios are covered in this blog post: Organizing your Firebase-enabled Android app builds.
Rather than using google-services.json
to drive initialisation of Firebase (assuming that's what you're currently doing?), I'd suggest dynamically creating FirebaseApp
using something like following
String apiKey;
String databaseUrl;
if (useDebugDatabase) {
apiKey = "xxxxxx";
databaseUrl = "<debug firebase database url>";
} else {
apiKey = "xxxxxx"
databaseUrl = "<release firebase database url>";
}
FirebaseOptions firebaseOptions = new FirebaseOptions.Builder()
.setApiKey(apiKey)
.setApplicationId(context.getString(R.string.google_app_id))
.setDatabaseUrl(databaseUrl)
.build();
FirebaseApp firebaseApp = FirebaseApp.initializeApp(context, firebaseOptions, "MyApp");
FirebaseDatabase database = FirebaseDatabase.getInstance(firebaseApp);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With