Android firebase java.lang.IllegalStateException导致的崩溃
我的应用程序用户已经收到这个错误相当长一段时间了。我不能用物理或虚拟设备自己复制它。它发生在on create方法中。此异常仅针对活动中的第一个firebase实例引发Android firebase java.lang.IllegalStateException导致的崩溃,android,firebase,Android,Firebase,我的应用程序用户已经收到这个错误相当长一段时间了。我不能用物理或虚拟设备自己复制它。它发生在on create方法中。此异常仅针对活动中的第一个firebase实例引发 java.lang.RuntimeException: at android.app.ActivityThread.performLaunchActivity (Unknown Source:621) at android.app.ActivityThread.handleLaunchActivity (Unknown
java.lang.RuntimeException:
at android.app.ActivityThread.performLaunchActivity (Unknown Source:621)
at android.app.ActivityThread.handleLaunchActivity (Unknown Source:47)
at android.app.servertransaction.LaunchActivityItem.execute (Unknown Source:63)
at android.app.servertransaction.TransactionExecutor.executeCallbacks (Unknown Source:77)
at android.app.servertransaction.TransactionExecutor.execute (Unknown Source:73)
at android.app.ActivityThread$H.handleMessage (Unknown Source:43)
at android.os.Handler.dispatchMessage (Unknown Source:19)
at android.os.Looper.loop (Unknown Source:249)
at android.app.ActivityThread.main (Unknown Source:98)
at java.lang.reflect.Method.invoke (Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (Unknown Source:11)
at com.android.internal.os.ZygoteInit.main (Unknown Source:282)
Caused by: java.lang.IllegalStateException:
at com.google.android.gms.common.internal.Preconditions.checkState (Unknown Source:29)
at com.google.firebase.FirebaseApp.initializeApp
at com.pocketchunk.pocketchunk.ui.login.PanelActivity.getClientId (PanelActivity.java:922)
at com.pocketchunk.pocketchunk.ui.login.PanelActivity.onCreate (PanelActivity.java:175)
at android.app.Activity.performCreate (Unknown Source:19)
at android.app.Activity.performCreate (Unknown Source:1)
at android.app.Instrumentation.callActivityOnCreate (Unknown Source:3)
at android.app.ActivityThread.performLaunchActivity (Unknown Source:376)
此异常仅由此特定firebase实例引发,即使活动中还有五个其他实例,并且当我删除它时,没有崩溃
第175行的方法调用:
getClientId(uid)
第922行的方法:
public void getClientId(String uid){
FirebaseOptions options66222 = new FirebaseOptions.Builder()
.setApplicationId(appID)
.setApiKey(key)
.setDatabaseUrl(url)
.build();
FirebaseApp.initializeApp(PanelActivity.this, options66222, "client_id");
FirebaseApp DB2123 = FirebaseApp.getInstance("client_id");
FirebaseDatabase DB2123Intance = FirebaseDatabase.getInstance(DB2123);
FirebaseDatabase.getInstance().setPersistenceEnabled(false);
DatabaseReference DB2123Reference = DB2123Intance.getReference().child("clientid").child(uid);
// Read from the database
DB2123Reference.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
// This method is called once with the initial value and again
// whenever data at this location is updated.
String clientid = dataSnapshot.getValue(String.class);
Log.i("TAG", "Value is: " + clientid);
final SharedPreferences userPrefs = getSharedPreferences("USER_PREFS", MODE_PRIVATE);
SharedPreferences.Editor editor = userPrefs.edit();
editor.putString("whmcsClientid", clientid);
editor.commit();
}
@Override
public void onCancelled(DatabaseError error) {
// Failed to read value
Log.i("TAG", "Failed to read value.", error.toException());
}
});
}
如有任何见解,将不胜感激 它似乎在以下位置崩溃:
com.google.android.gms.common.internal.premissions.checkState(未知来源:29)
。哪一行是922?922是firbase数据库实例初始化,所以问题是,两边的配置都正确了吗。再次检查配置设置。当然,还要确保在应用程序的OnCreate方法中调用Firebase初始化。我有多个使用同一数据库的firebase实例。