Firebase身份验证不会创建帐户

时间:2019-08-04 05:13:06

标签: android firebase firebase-authentication

我不知道我的代码或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)

1 个答案:

答案 0 :(得分:0)

尝试在onCreate方法中获取类的实例,然后尝试。如果这样做不起作用,请发布正确的错误堆栈跟踪。通过此方法,我们无法确定错误的发生位置和原因。

堆栈跟踪显示电子邮件格式错误。这意味着您输入的电子邮件地址无效或格式错误。请确保输入正确的地址。尝试检查原始电子邮件地址并调试并检查值正在接受输入。请随时发表评论。

在userInputArrayList中,您正在获取电子邮件和密码。我假设该arraylist中仅存储两个字段.arrayList以编程方式从'0'开始。因此,尝试为电子邮件输入get(0)和get( 1)输入密码。希望有帮助