Я пытаюсь добавить нового пользователя в Firebase через Android и получаю сообщение об ошибке, которое не имеет смысла для меня. У меня включена электронная почта / пароль для входа в консоль Firebase. Я получаю сообщение об ошибке:
com.example.myproject D / RegisterActivity: validateForm: LoginActivity validateForm запущен. com.example.myproject I / BiChannelGoogleApi: [FirebaseAuth:] getGoogleApiForMethod () вернул Gms: com.google.firebase.auth.api.internal.zzao@xyz123
com.example.myproject W / FirebaseMethods: createUser: fail com.google.firebase.FirebaseException: произошла внутренняя ошибка. [7:]
Моя кодовая база выглядит следующим образом:
public class FirebaseMethods {
private static final String TAG = "FirebaseMethods";
// declare Firebase auth
private FirebaseAuth mAuth;
private String user;
private Context mContext;
public FirebaseMethods(Context context){
mAuth = FirebaseAuth.getInstance();
mContext = context;
if(mAuth.getCurrentUser() != null){
user = mAuth.getCurrentUser().getUid();
}
}
/**
* Register a new username and email to Firebase authentication
* @param email
* @param password
* @param username
*/
public void registerNewEmail(String email, String password, String username){
mAuth.createUserWithEmailAndPassword(email, password)
.addOnCompleteListener(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
Log.d(TAG, "createUserWithEmail:success");
FirebaseUser user = mAuth.getCurrentUser();
updateUI(user);
} else {
// If sign in fails, display a message to the user.
Log.w(TAG, "createUserWithEmail:failure", task.getException());
Toast.makeText(mContext, "Authentication failed.", Toast.LENGTH_SHORT).show();
updateUI(null);
}
}
});
}
private void updateUI(FirebaseUser user) {
Log.d(TAG, "updateUI: LoginActivity updateUI started.");
if (user != null) {
/*If the user is already logged in then navigate back to the MainActivity.*/
Intent intent = new Intent(mContext, MainActivity.class);
mContext.startActivity(intent);
} else {
//add alternative action here
}
}
