问题描述
我正在开发一个Android应用,并尝试使用Firebase数据库.我试图将数据写入数据库,但未显示任何内容(通过Firebase控制台检查).我在构建中有Firebase库:
I am working on an Android app and trying to use Firebase Database. I tried to write data to the Database but nothing was showing up (checked via Firebase console). I have Firebase libraries in the build:
implementation platform('com.google.firebase:firebase-bom:26.2.0')
implementation 'com.google.firebase:firebase-database'
根据Firebease控制台,我的Firebase数据库URL是:
My Firebase Database URL as per Firebease console is :
https://xxxxxxxx-xxxxxxx-default-rtdb.europe-west1.firebasedatabase.app/
而当我从代码中获得对它的引用时:
whereas when I get a reference to it from the code:
private DatabaseReference mDatabase;
mDatabase = FirebaseDatabase.getInstance().getReference();
Log.i(TAG," Reference is: "+mDatabase.toString());
logcat显示以下响应:
The logcat shows below response:
I/Tag: Reference is: https://xxxxxxxx-xxxxxxx-default-rtdb.firebaseio.com
我在项目中还拥有google-services.json文件,该文件指向Firebase控制台中显示的相同数据库URL.在我看来,Firebase在我看不到/配置的某个地方错误地配置了我的数据库.
I also have the google-services.json file in the project which points to the same database URL shown in the Firebase console. It appears to me that Firebase has misconfigured my database somewhere which I can't see / configure.
有什么我想念的吗?
推荐答案
我最近遇到了类似的问题,,Firebase URL也为空,通过删除应用程序的 build 文件夹并再次重建项目,使它正常工作
I recently faced a similar issue, Firebase URL is null even after updating google_services.json,I got it working by deleting the build folder of my app and rebuilding the project again
这篇关于Firebase数据库指向错误的数据库URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!