Firebase 数据库指向错误的数据库 URL [英] Firebase Database points to wrong database URL
问题描述
我正在开发 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.
有什么我遗漏的吗?
推荐答案
我最近遇到了类似的问题,即使在更新 google_services.json 之后 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!