gpt4 book ai didi

android - 未能获取 FirebaseDatabase 实例。在 FirebaseApp 中指定 DatabaseURL

转载 作者:行者123 更新时间:2023-12-03 16:29:07 24 4
gpt4 key购买 nike

FirebaseApp 调用时抛出异常 FirebaseDatabase.getInstance() .
错误信息

Failed to get FirebaseDatabase instance: Specify DatabaseURL withinFirebaseApp or from your getInstance() call.

Firebase项目配置正确。 Authentication正常工作,但无法连接到 firebase .
这是我的应用级 gradle.build 文件
build.gradle
dependencies {
.....

//Firebase database
implementation 'com.google.firebase:firebase-database:11.6.2'
// Firebase Invitation
implementation 'com.google.firebase:firebase-invites:11.6.2'
// Firebase Authentication
implementation 'com.google.firebase:firebase-auth:11.6.2'
// Google Sign In SDK (only required for Google Sign In)
implementation 'com.google.android.gms:play-services-auth:11.6.2'

// people api request libraries
implementation 'com.google.api-client:google-api-client:1.22.0'
implementation 'com.google.api-client:google-api-client-android:1.22.0'
implementation 'com.google.apis:google-api-services-people:v1-rev4-1.22.0'
compile project(':customsupport')
}

apply plugin: 'com.google.gms.google-services'
和项目级 build.gradle 文件
buildscript {
repositories {
jcenter()
maven { url 'https://maven.fabric.io/public' }
}

dependencies {
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.google.gms:google-services:3.1.2'

// We recommend changing it to the latest version from our changelog:
// https://docs.fabric.io/android/changelog.html#fabric-gradle-plugin
classpath 'io.fabric.tools:gradle:1.24.4'
}
}
一个 数据库异常 将发生在 FirebaseDatabase.class
public static synchronized FirebaseDatabase getInstance(FirebaseApp var0, String var1) {
if(TextUtils.isEmpty(var1)) {
throw new DatabaseException("Failed to get FirebaseDatabase instance: Specify DatabaseURL within FirebaseApp or from your getInstance() call.");
} else {
...
}

最佳答案

如果有人在 2021 年遇到这个问题,那么只需按照以下步骤操作:-
在 build.gradle/app 中添加这些依赖项

  implementation platform('com.google.firebase:firebase-bom:26.3.0')
implementation 'com.google.firebase:firebase-database-ktx'
然后使用 databasereference 对象
databaseReference=Firebase.database.getReference("Users")
仍然感到困惑,然后在此处阅读此文档 1

关于android - 未能获取 FirebaseDatabase 实例。在 FirebaseApp 中指定 DatabaseURL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47730910/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com