【发布时间】:2019-08-04 05:13:06
【问题描述】:
我不知道我的代码或 Firebase 控制台出了什么问题,但是当我运行应用程序并单击提交按钮尝试创建一个帐户时,它会运行 .addOnFailureListener,但我不知道为什么。
很抱歉描述模糊,但如果有人能告诉我是否做错了什么,我将非常感激。
FirebaseFirestore db = FirebaseFirestore.getInstance();
private FirebaseAuth mAuth = FirebaseAuth.getInstance();
private TextView mTextMessage;
private StorageReference mStorageRef;
@Override
@TargetApi(24)
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_create_account_page);
//creating user if all previous data validation checks out
if (nextPage == true) {mAuth.createUserWithEmailAndPassword(userInputArrayList.get(1), userInputArrayList.get(2)).addOnCompleteListener(CreateAccountPage.this, new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
if (task.isSuccessful()) {
Log.d(TAG,"9");
// Sign in success, update UI with the signed-in user's information
Log.d(TAG,"Sign up Successful");
FirebaseUser user = mAuth.getCurrentUser();
updateUI(user, userInputArrayList, tglBtnAdmin);
} else {
// If sign in fails, display a message to the user.
showToast("Could not create an account, please try again later.");
}
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
showToast("Account could not be created, please try again later");
}
});
}
} else {
showToast("Please fill all fields.");
}
}
});
}
}
错误信息
com.google.firebase.auth.FirebaseAuthInvalidCredentialsException: The email address is badly formatted.
at com.google.firebase.auth.api.internal.zzdr.zzb(Unknown Source:30)
at com.google.firebase.auth.api.internal.zzeu.zza(Unknown Source:16)
at com.google.firebase.auth.api.internal.zzen.zzc(Unknown Source:33)
at com.google.firebase.auth.api.internal.zzep.onFailure(Unknown Source:49)
at com.google.firebase.auth.api.internal.zzdx.dispatchTransaction(Unknown Source:18)
at com.google.android.gms.internal.firebase_auth.zza.onTransact(Unknown Source:13)
at android.os.Binder.execTransact(Binder.java:697)
【问题讨论】:
-
你能记录在 onFailureListener 中传递的异常吗?您给出的错误描述性不强。
-
@doug 抱歉,我已经对其进行了编辑以显示正确的错误。我仍然不确定我应该做什么。
-
错误消息显示“电子邮件地址格式错误。”你认为这意味着什么?
-
@Dipin 谢谢!我做了同样的事情并为数组列表设置了错误的数字。
标签: android firebase firebase-authentication