请帮助查找有关我的代码的问题,它总是转到addOnFailureListener并向我返回失败消息。 这是在我的日志中(发生了网络错误(例如超时,连接中断或主机不可达)。)
auth.createUserWithEmailAndPassword(
edittext_email.getText().toString(),
edittext_password.getText().toString()
).addOnSuccessListener(
new OnSuccessListener<AuthResult>() {
@Override
public void onSuccess(AuthResult authResult) {
Victim victim = new Victim();
victim.setEmail(edittext_email.getText().toString());
victim.setPassword(edittext_password.getText().toString());
victim.setName(edittext_name.getText().toString());
victim.setPhone(edittext_phone.getText().toString());
victimuser.child(FirebaseAuth.getInstance().getCurrentUser().getUid())
.setValue(victim)
.addOnSuccessListener(
new OnSuccessListener<Void>() {
@Override
public void onSuccess(Void aVoid) {
Snackbar.make(rootLayout,"Registered!",Snackbar.LENGTH_SHORT).show();
}
}
).addOnFailureListener(
new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Snackbar.make(rootLayout,"Failed in Registration" +e.getMessage(), Snackbar.LENGTH_SHORT).show();
}
}
);
}
}
).addOnFailureListener(
new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Snackbar.make(rootLayout,"Failed", Snackbar.LENGTH_SHORT).show();
Log.d(TAG,"Failed saving on Firebase: "+ e.getMessage());
}
}
);