in the Google I/O 2016 sessions the big improvements towards full integration of Firebase has been shown. In my apps, I'm trying to migrate to the new solution(s) but have several questions. One of them is the following:
In my Firebase apps, I used a parameter to define the Firebase database as follows (gradle):
gradle.properties file:
FIREBASE_REF_REL="https://xxxxxxx.firebaseio.com/"
FIREBASE_REF_DEB="https://xxxxxxx-dev.firebaseio.com/"
build.gradle file:
buildTypes {
debug {
minifyEnabled false
multiDexEnabled true
it.buildConfigField 'String', 'FIREBASE_ROOT_URL', FIREBASE_REF_DEB
}
release {
minifyEnabled true
useProguard true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
zipAlignEnabled true
it.buildConfigField 'String', 'FIREBASE_ROOT_URL', FIREBASE_REF_REL
}
return true
}
This allowed me to run my debug apps against a debug Firebase environment which helped me to test changes in the datamodel and security rules without affecting the production environment.
In the new Firebase solution this does not seem possible anymore because of the generated google-services.json
file which contains the Firebase reference (as explained here: https://firebase.google.com/support/guides/firebase-android#import_your_project_to_the_new_firebase_console_numbered).
When trying to reference my debug database I get the following type of errors:
Caused by: com.google.firebase.database.DatabaseException: Invalid URL (https://xxxxxxx-dev.firebaseio.com/) passed to getReference(). URL was expected to match configured Database URL: https://xxxxx.firebaseio.com
My question: what is the correct way/best practice to run an app against a test Firebase database in the new situation?
Once you enable debug mode on your development devices, navigate to DebugView by selecting the arrow next to StreamView on the top nav of Google Analytics and selecting DebugView. Then, just start using your app to see your app's events being logged in the DebugView report.
Enable debug mode by passing the -FIRDebugEnabled argument to the application. You can add this argument in the application's Xcode scheme. When debug mode is enabled via -FIRDebugEnabled, further executions of the application will also be in debug mode.
I am not sure that it is the best practice.
You can use different google-services.json
files.
I am investiganting about the current plugin (com.google.gms:google-services:3.0.0
) if it supports build types.
The previous one (com.google.gms:google-services:2.1.X
) supported flavors but not types.
In any case you should be able to use somenthing like this:
app/src/release/google-services.json
app/google-services.json
In this case the plugin looks in the locations and stops when it finds a google-services.json
file.
In this way you should be able to use different firebase apps for debug and release.
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