gpt4 book ai didi

android - 默认FirebaseApp未初始化

转载 作者:行者123 更新时间:2023-12-02 10:56:10 28 4
gpt4 key购买 nike

我们在Android应用程序中看到了Default FirebaseApp is not initialized in this process com.example.app. Make sure to call FirebaseApp.initializeApp(Context) first.消息的一些异常(exception)情况,我们刚刚在其中添加了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组件:
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"

正如我看到的 from the documentationthe Javadoc一样,在这种情况下,我们不必手动进行任何初始化。

异常(exception)情况发生在各种设备上的Android 4-6上。

编辑:

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

最佳答案

我前段时间也遇到过同样的问题。
您正在尝试获取Firebase实例而不对其进行初始化。
在尝试在主函数或FutureBuilder中获取Firebase实例之前,请添加以下代码行:

FirebaseApp.initializeApp();

关于android - 默认FirebaseApp未初始化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63512704/

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