我正在尝试在Firebase中注册新用户,但由于某种原因它会返回错误。我正在使用android studio中的firebase工具进行连接 包com.parse.starter;
import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.Task;
import com.google.firebase.auth.AuthResult;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseUser;
public class MainActivity extends AppCompatActivity {
private FirebaseAuth mAuth;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mAuth = FirebaseAuth.getInstance();
mAuth.createUserWithEmailAndPassword("abraham_mew@yahoo.com", "123456789juk")
.addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
if (task.isSuccessful()) {
// Sign in success, update UI with the signed-in user's information
;
System.out.print("SUCKSESSS");
} else {
// If sign in fails, display a message to the user.
System.out.print(("FAILE"));
}
// ...
}
});
}
}
这是Logcat
Caused by: java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process com.parse.starter. 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)
at com.parse.starter.MainActivity.onCreate(MainActivity.java:22)