造成原因:java.lang.IllegalStateException:com.google.firebase.FirebaseApp.getInstance

时间:2019-12-18 03:24:20

标签: android firebase

`Caused by
  at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2988)
  at android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:3049)
  at android.app.ActivityThread.-wrap14 (ActivityThread.java)
  at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1646)
  at android.os.Handler.dispatchMessage (Handler.java:102)
  at android.os.Looper.loop (Looper.java:154)
  at android.app.ActivityThread.main (ActivityThread.java:6836)
  at java.lang.reflect.Method.invoke (Native Method)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:1520)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1410)
Caused by: java.lang.IllegalStateException: 
  at com.google.firebase.FirebaseApp.getInstance
  at com.google.firebase.auth.FirebaseAuth.getInstance (Unknown Source)
  at org.cocos2dx.lua.AppActivity.onCreate (AppActivity.java:128)
  at android.app.Activity.performCreate (Activity.java:6955)
  at android.app.Instrumentation.callActivityOnCreate (Instrumentation.java:1126)
  at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2931)`

我也曾搜索过类似的问题,并找到了解决方法

例如,检查firebase是否已初始化,但我不知道哪个是正确的。

`
if (FirebaseApp.getApps(context).isEmpty()) {
    FirebaseApp.initializeApp(context);
}`

`if (!FirebaseApp.getApps(context).isEmpty()) {
    mAuth = FirebaseAuth.getInstance();
}
`

Doc曾说过,启动应用程序后,firebase会自动初始化,并且此崩溃发生在一台android 7.0设备上。

任何人都可以告诉我原因是什么

0 个答案:

没有答案