從Android Vitals
收集的新故障部分和ANR之後,啓用persistence
後,我有幾個IllegalStateException
和firebase database
。IllegalStateException在啓用Firebase數據庫中的持久性時
public class Configuration extends Application {
@Override
public void onCreate() {
super.onCreate();
if(!FirebaseApp.getApps(this).isEmpty()) {
FirebaseDatabase.getInstance().setPersistenceEnable(true);
}
}
}
例外:
java.lang.RuntimeException:
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2339)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2494)
at android.app.ActivityThread.access$900(ActivityThread.java:157)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1356)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5530)
at java.lang.reflect.Method.invoke(Method.java:0)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:733)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:623)
Caused by: java.lang.IllegalStateException:
at com.google.firebase.FirebaseApp.getInstance(FirebaseApp.java:0)
at com.google.firebase.database.FirebaseDatabase.getInstance(FirebaseDatabase.java:0)
at <OR>.getInstance(FirebaseDatabase.java:0)
at <OR>.setPersistenceEnabled(FirebaseDatabase.java:0)
at <OR>.zziE(FirebaseDatabase.java:0)
at myapp.MyActivity.<init>(MyActivity.java:0)
at java.lang.Class.newInstance(Class.java:0)
at android.app.Instrumentation.newActivity(Instrumentation.java:1068)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2329)
更新2018年2月3日
根據@Frank麪包車Puffelen的我創造了這個answer的建議,但仍然出現問題。
今天9:14應用版本27 LGE LG K8(mm1v),1536MB內存,安卓6.0 報告1
java.lang.RuntimeException:
at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2339)
at android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:2494)
at android.app.ActivityThread.access$900 (ActivityThread.java:157)
at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1356)
at android.os.Handler.dispatchMessage (Handler.java:102)
at android.os.Looper.loop (Looper.java:148)
at android.app.ActivityThread.main (ActivityThread.java:5551)
at java.lang.reflect.Method.invoke (Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:731)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:621)
Caused by: java.lang.IllegalStateException:
at com.google.firebase.FirebaseApp.getInstance (FirebaseApp.java)
at com.google.firebase.database.FirebaseDatabase.getInstance (FirebaseDatabase.java)
or .setPersistenceEnabled (FirebaseDatabase.java)
or .zzph (FirebaseDatabase.java)
at myapp.MyActivity.<init> (MyActivity.java)
at java.lang.Class.newInstance (Class.java)
at android.app.Instrumentation.newActivity (Instrumentation.java:1068)
at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2329)
at android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:2494)
at android.app.ActivityThread.access$900 (ActivityThread.java:157)
at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1356)
at android.os.Handler.dispatchMessage (Handler.java:102)
at android.os.Looper.loop (Looper.java:148)
at android.app.ActivityThread.main (ActivityThread.java:5551)
at java.lang.reflect.Method.invoke (Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:731)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:621)
參見[火力地堡的數據庫持久不工作#15](https://github.com/firebase/quickstart-android/issues/15) –
搜索您的代碼其他對'setPersistenceEnable()'的調用。如果崩潰是'Configuration.onCreate()'中調用的結果,那麼我希望看到堆棧跟蹤中與創建應用程序相關的行,例如'android.app.Instrumentation.callApplicationOnCreate'。相反,有一些行提示系統正在嘗試創建「MyActivity」實例。 –
@языкK - 我已經從應用程序類中刪除了代碼並使用瞭解決方案的建議代碼,但它沒有解決問題,它仍然生成錯誤日誌。 – k4k4sh1