我的应用程序用户已经有一段时间出现此错误了。我无法使用物理或虚拟设备复制它。它发生在on create方法中。仅针对活动中的第一个Firebase实例抛出此异常。
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());
}
});
}
任何见识将不胜感激!