默认FirebaseApp未初始化 [英] Default FirebaseApp is not initialized

查看:400
本文介绍了默认FirebaseApp未初始化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们在Android应用程序中看到了消息Default FirebaseApp is not initialized in this process com.example.app. Make sure to call FirebaseApp.initializeApp(Context) first.的一些例外,其中我们刚刚添加了Firebase Remote Config.

We're seeing a few exceptions with the message Default FirebaseApp is not initialized in this process com.example.app. Make sure to call FirebaseApp.initializeApp(Context) first. in our Android app in which we just added Firebase Remote Config.

堆栈跟踪如下:

Fatal Exception: java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process com.example.app. Make sure to call FirebaseApp.initializeApp(Context) first.
       at com.google.firebase.FirebaseApp.getInstance(Unknown Source)
       at com.google.firebase.remoteconfig.FirebaseRemoteConfig.getInstance(Unknown Source)
       at com.example.app.fragments.SomeFragment.updateFooter(SourceFile:295)
       at com.example.app.fragments.SomeFragment.onCreateView(SourceFile:205)
       at android.support.v4.app.Fragment.performCreateView(SourceFile:2080)
       at android.support.v4.app.FragmentManagerImpl.moveToState(SourceFile:1108)
       at android.support.v4.app.FragmentManagerImpl.moveToState(SourceFile:1290)
       at android.support.v4.app.BackStackRecord.run(SourceFile:801)
       at android.support.v4.app.FragmentManagerImpl.execSingleAction(SourceFile:1638)
       at android.support.v4.app.BackStackRecord.commitNowAllowingStateLoss(SourceFile:679)
       at android.support.v4.app.FragmentPagerAdapter.finishUpdate(SourceFile:143)
       at android.support.v4.view.ViewPager.populate(SourceFile:1240)
       at android.support.v4.view.ViewPager.populate(SourceFile:1088)
       at android.support.v4.view.ViewPager.setAdapter(SourceFile:542)
       at com.example.app.SomeActivity.onSomeAsyncCallback(SourceFile:908)
       at com.example.app.SomeDataRetriever.onAsyncHttpCompleted(SourceFile:72)
       at com.example.app.io.AsyncHttp.onPostExecute(SourceFile:141)
       at com.example.app.io.AsyncHttp.onPostExecute(SourceFile:19)
       at android.os.AsyncTask.finish(AsyncTask.java:679)
       at android.os.AsyncTask.access$500(AsyncTask.java:180)
       at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:696)
       at android.os.Handler.dispatchMessage(Handler.java:102)
       at android.os.Looper.loop(Looper.java:150)
       at android.app.ActivityThread.main(ActivityThread.java:5665)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:799)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:689)

这是版本9.6.1,我们还使用了其他Firebase组件:

This is version 9.6.1 and we're also using other Firebase components:

compile 'com.google.firebase:firebase-ads:9.6.1'
compile 'com.google.firebase:firebase-config:9.6.1'
compile 'com.google.firebase:firebase-invites:9.6.1'
compile "com.google.firebase:firebase-messaging:9.6.1"

我从文档中看到 Javadoc 在这种情况下,我们不必进行任何手动初始化

As I can see from the documentation and the Javadoc we shouldn't have to do any manual initialization in our case.

例外情况发生在各种设备上的Android 4-6上.

The exception happens on Android 4-6 on a variety of devices.

我看到这个问题引起了一点关注.我认为这种解释对您中的某些人可能很有趣: https://firebase.googleblog.com/2016/12/how-does-firebase-initialize-on-android.html

I see this question gets a little bit of attention. I think this explanation can be interesting for some of you: https://firebase.googleblog.com/2016/12/how-does-firebase-initialize-on-android.html

推荐答案

我前段时间也遇到过同样的问题.

I had this same issue some time ago.

您正尝试获取Firebase实例而不对其进行初始化. 在尝试获取Firebase实例之前,请添加以下代码行:

You're trying to get an instance of Firebase without initialize it. Please add this line of code before you try to get an instance of Firebase:

FirebaseApp.initializeApp(this);

这篇关于默认FirebaseApp未初始化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆