Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run debug app version on a 'debug' Firebase database

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?

like image 295
Peter Avatar asked May 21 '16 09:05

Peter


People also ask

How do I use debug view in firebase?

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.

How do I enable FIRDebugEnabled?

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.


1 Answers

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.

like image 137
Gabriele Mariotti Avatar answered Oct 11 '22 14:10

Gabriele Mariotti