java - Firebase Android "using Firebase.setAndroidContext() before using Firebase."错误

标签 java android firebase

我在 android v2.2.0 上使用 firebase 该应用程序大部分时间都运行良好。 但是当我长时间离开应用程序(比方说 2-3 小时以上)并返回应用程序时,它很可能会出错。

并发送错误报告以始终检查此报告。

Caused by: java.lang.RuntimeException: You need to set the Android context using Firebase.setAndroidContext() before using Firebase.

我已经在 onCreate() 的顶部设置了;在每项 Activity 上作为 www.firebase.com 的安装指南

@Override
public void onCreate() {
    super.onCreate();
    Firebase.setAndroidContext(this);
    // other setup code
}

我应该修复什么?

最佳答案

In the new SDK, it's no longer necessary to call Firebase.setAndroidContext() so you can remove it from your code.

链接:https://firebase.google.com/support/guides/firebase-android#setting_the_android_context_and_enabling_offline_persistence_numbered

关于java - Firebase Android "using Firebase.setAndroidContext() before using Firebase."错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33250100/

相关文章:

javascript - getIdToken() 不是函数,即使它在 firebase 文档中像函数一样使用

java - 我想添加实时 Firebase 数据库中的值

java - Android SQLite 中的原始查询 - 插入或忽略

java - 我想使用 NCDC(国家气候数据中心)气候数据 API 根据邮政编码获取美国过去的最高和最低气温

java - 如何测试转换是否会导致错误?

android - ARCore——检测墙壁

java - Intellij 不构建类

android - 如果使用的资源 ID 属于另一个 Activity 布局,如何显示警告/错误

android - 将协程更新到 1.2.0 : META-INF/atomicfu. kotlin_module 后构建失败

javascript - 从 Google Cloud Function 检查 Google Speech API 操作