因此,我试图启动并运行我的第一个应用程序,尝试在手机上对其进行调试时遇到问题。 的错误状态
Caused by: java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process com.stuff.morestuff. Make sure to call FirebaseApp.initializeApp(Context) first.
at com.google.firebase.FirebaseApp.getInstance(SourceFile:218)
at com.google.firebase.auth.FirebaseAuth.getInstance(Unknown Source:1)
at com.stuff.morestuff.MainActivity.<init>(MainActivity.java:13)
我尝试使用FirebaseApp.initializeApp(this)
,但仍然会引发相同的错误。
public class MainActivity extends AppCompatActivity {
private FirebaseAuth mAuth;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//I've tried using this too but it didn't change anything, still the same error
//FirebaseApp.initializeApp(this);
mAuth = FirebaseAuth.getInstance();
}
@Override
public void onStart() {
super.onStart();
// Check if user is signed in (non-null) and update UI accordingly.
FirebaseUser currentUser = mAuth.getCurrentUser();
if(currentUser == null){
Intent startIntent = new Intent(MainActivity.this, StartActivity.class);
startActivity(startIntent);
}
}
}
我错过了什么吗?
答案 0 :(得分:0)
此解决方案对我有用。 **备注如果要使用 public simplePOVgames: ICommonGameCard[] = [];
private addGameCard(gamecard: ICommonGameCard): void {
gamecard.pov === POVType.Simple
? this.simplePOVgames.push(gamecard)
: this.freePOVgames.push(gamecard);
}