如何在“调试”Firebase数据库上运行调试应用程序版本 [英] How to run debug app version on a 'debug' Firebase database
问题描述
在我的Firebase应用程序中,我使用了一个参数来定义Firebase数据库(gradle):
gradle.properties文件:
FIREBASE_REF_REL =https://xxxxxxx.firebaseio.com/
FIREBASE_REF_DEB =https://xxxxxxx-dev.firebaseio.com/
建立.gradle文件:
$ p $ 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
}
这使我可以运行我的调试应用程序调试Firebase环境,帮助我测试数据模型和安全规则的变化,而不影响生产环境。在新的Firebase解决方案中,这似乎不再可能,因为生成的包含Firebase参考的 google-services.json
文件(如此处所述: https://firebase.google.com/support/guides/firebase-android#import_your_project_to_the_new_firebase_console_numbered )。
在尝试引用我的调试数据库时,出现以下类型的错误:
由com.google.firebase.database.DatabaseException导致:无效的URL(https://xxxxxxx-dev.firebaseio.com/)传递给getReference()。 URL预计会匹配配置的数据库URL:https://xxxxx.firebaseio.com
我的问题:在新的情况下,运行应用程序对测试Firebase数据库的正确方法/最佳实践是什么? 我不是肯定这是最好的做法。
您可以使用不同的 google-services.json
文件。
我正在调查当前插件( com.google.gms:google-services:3.0.0
),如果它支持构建类型的话。
前一个( com.google.gms:google-services:2.1.X
)支持风格,但不支持类型。
在任何情况下,您都应该可以使用如下所示:
app / src / release / google -services.json
app / google-services.json
在这种情况下,插件看起来像在找到 google-services.json
文件时停止。
通过这种方式,您应该能够使用不同的firebase应用程序进行调试和发布。
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?
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.
这篇关于如何在“调试”Firebase数据库上运行调试应用程序版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!