Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Android:Firebase登录失败密码无效或用户没有密码_Java_Android_Firebase_Firebase Authentication - Fatal编程技术网

Java Android:Firebase登录失败密码无效或用户没有密码

Java Android:Firebase登录失败密码无效或用户没有密码,java,android,firebase,firebase-authentication,Java,Android,Firebase,Firebase Authentication,我正在尝试创建一个简单的应用程序,用户的个人资料使用firebase,我遇到了一个问题。注册功能运行良好,我可以在Firebase控制台中看到已注册的帐户,但登录不起作用。我得到“密码无效或用户没有密码。”异常。谁能帮我做这个吗。我的登录方法键入如下 private void userLogin(){ String email = emailText.getText().toString().trim(); String password = passwordText.getT

我正在尝试创建一个简单的应用程序,用户的个人资料使用firebase,我遇到了一个问题。注册功能运行良好,我可以在Firebase控制台中看到已注册的帐户,但登录不起作用。我得到“密码无效或用户没有密码。”异常。谁能帮我做这个吗。我的登录方法键入如下

 private void userLogin(){
    String email = emailText.getText().toString().trim();
    String password = passwordText.getText().toString().trim();


    if (TextUtils.isEmpty(email)){
        Toast.makeText(this,"Please enter email", Toast.LENGTH_SHORT).show();
        return;
    }
    if (TextUtils.isEmpty(password)) {
        Toast.makeText(this,"Please enter password", Toast.LENGTH_SHORT).show();
        return;
    }
    firebaseAuth.signInWithEmailAndPassword(email, password)
            .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
                @Override
                public void onComplete(@NonNull Task<AuthResult> task) {
                   if(task.isSuccessful()){
                       Toast.makeText(LogIn.this,"You are logged in", Toast.LENGTH_SHORT).show();
                   }
                   else{
                       Toast.makeText(LogIn.this,"MISTAKE", Toast.LENGTH_SHORT).show();
                       Log.d("z", "onComplete: Failed=" + task.getException().getMessage());
                   }
                }
            });
}

我已经使用了此代码,并且工作正常。同时检查您的firebase身份验证规则部分,其中必须启用电子邮件和密码

    FirebaseAuth mAuth;
      mAuth = FirebaseAuth.getInstance();


   final String email=username.getText().toString();
        final String password=pass.getText().toString();
        Log.d("12345",email+password);
        if(email.equals("")||password.equals(""))
            Toast.makeText(LogIn.this,"Fill both",Toast.LENGTH_SHORT).show();
        else
        {
            mProgressDialog.setMessage("Login....");
            mProgressDialog.show();
            mAuth.signInWithEmailAndPassword(email, password)
                    .addOnCompleteListener(LogIn.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
                                Log.d("12345", "signInWithEmail:success");


                                    Toast.makeText(LogIn.this,"valid email",Toast.LENGTH_LONG).show();

                                mProgressDialog.dismiss();
                                //updateUI(user);
                            } else {
                                // If sign in fails, display a message to the user.
                                Log.w("12345", "signInWithEmail:failure", task.getException());
                                mProgressDialog.dismiss();
                                Toast.makeText(LogIn.this, "Authentication failed.",
                                        Toast.LENGTH_SHORT).show();
                            }
                        }
                    });
        }
FirebaseAuth-mAuth;
mAuth=FirebaseAuth.getInstance();
最终字符串email=username.getText().toString();
最终字符串密码=pass.getText().toString();
Log.d(“12345”,电子邮件+密码);
if(email.equals(“”)| | password.equals(“”)
Toast.makeText(LogIn.this,“填充两个”,Toast.LENGTH_SHORT.show();
其他的
{
设置消息(“登录…”);
mProgressDialog.show();
mAuth.使用电子邮件和密码登录(电子邮件,密码)
.addOnCompleteListener(LogIn.this,新的OnCompleteListener(){
@凌驾
未完成的公共void(@NonNull任务){
if(task.issusccessful()){
//登录成功,使用登录用户的信息更新UI
Log.d(“12345”,“通过电子邮件登录:成功”);
Toast.makeText(LogIn.this,“valid email”,Toast.LENGTH_LONG.show();
mProgressDialog.disclose();
//updateUI(用户);
}否则{
//如果登录失败,则向用户显示消息。
Log.w(“12345”,“signInWithEmail:failure”,task.getException());
mProgressDialog.disclose();
Toast.makeText(LogIn.this,“身份验证失败”,
吐司。长度(短)。show();
}
}
});
}

我已经使用了此代码,并且工作正常。另外,请检查您的firebase身份验证规则部分,其中必须启用电子邮件和密码

    FirebaseAuth mAuth;
      mAuth = FirebaseAuth.getInstance();


   final String email=username.getText().toString();
        final String password=pass.getText().toString();
        Log.d("12345",email+password);
        if(email.equals("")||password.equals(""))
            Toast.makeText(LogIn.this,"Fill both",Toast.LENGTH_SHORT).show();
        else
        {
            mProgressDialog.setMessage("Login....");
            mProgressDialog.show();
            mAuth.signInWithEmailAndPassword(email, password)
                    .addOnCompleteListener(LogIn.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
                                Log.d("12345", "signInWithEmail:success");


                                    Toast.makeText(LogIn.this,"valid email",Toast.LENGTH_LONG).show();

                                mProgressDialog.dismiss();
                                //updateUI(user);
                            } else {
                                // If sign in fails, display a message to the user.
                                Log.w("12345", "signInWithEmail:failure", task.getException());
                                mProgressDialog.dismiss();
                                Toast.makeText(LogIn.this, "Authentication failed.",
                                        Toast.LENGTH_SHORT).show();
                            }
                        }
                    });
        }
FirebaseAuth-mAuth;
mAuth=FirebaseAuth.getInstance();
最终字符串email=username.getText().toString();
最终字符串密码=pass.getText().toString();
Log.d(“12345”,电子邮件+密码);
if(email.equals(“”)| | password.equals(“”)
Toast.makeText(LogIn.this,“填充两个”,Toast.LENGTH_SHORT.show();
其他的
{
设置消息(“登录…”);
mProgressDialog.show();
mAuth.使用电子邮件和密码登录(电子邮件,密码)
.addOnCompleteListener(LogIn.this,新的OnCompleteListener(){
@凌驾
未完成的公共void(@NonNull任务){
if(task.issusccessful()){
//登录成功,使用登录用户的信息更新UI
Log.d(“12345”,“通过电子邮件登录:成功”);
Toast.makeText(LogIn.this,“valid email”,Toast.LENGTH_LONG.show();
mProgressDialog.disclose();
//updateUI(用户);
}否则{
//如果登录失败,则向用户显示消息。
Log.w(“12345”,“signInWithEmail:failure”,task.getException());
mProgressDialog.disclose();
Toast.makeText(LogIn.this,“身份验证失败”,
吐司。长度(短)。show();
}
}
});
}

我遇到了同样的问题,只是后来才意识到我用错误的资源id初始化了密码字段。确保这些都是正确的

我遇到了同样的问题,只是后来才意识到我用错误的资源id初始化了密码字段。确保这些都是正确的

TL;医生:

检查您是否正在传递字符串值,而不是对EditText的引用

冗长:

在我的例子中,问题是我在
FirebaseAuth.createUserWithEmailAndPassword()
中传递了一个Edittext引用作为密码参数,而不是字符串。把它放在上下文中,我在做:

mAuth.createUserWithEmailAndPassword(validEmail, edittext.text)
而不是

mAuth.createUserWithEmailAndPassword(validEmail, edittext.text.toString())

许多用户已经使用
edittext.text
引用而不是他们输入的密码创建。这就是为什么他们在尝试使用实际选择的密码登录时会出现错误。

TL;医生:

检查您是否正在传递字符串值,而不是对EditText的引用

冗长:

在我的例子中,问题是我在
FirebaseAuth.createUserWithEmailAndPassword()
中传递了一个Edittext引用作为密码参数,而不是字符串。把它放在上下文中,我在做:

mAuth.createUserWithEmailAndPassword(validEmail, edittext.text)
而不是

mAuth.createUserWithEmailAndPassword(validEmail, edittext.text.toString())

许多用户已经使用
edittext.text
引用而不是他们输入的密码创建。这就是为什么他们每次尝试使用实际选择的密码登录时都会出现错误。

谢谢您的回答,但此代码也不起作用。我遇到了与以前相同的异常“密码无效或用户没有密码”。firebase身份验证规则部分如何。我不确定我是否理解您的意思,授权提供程序中启用了电子邮件和密码,我还应该做什么?谢谢您的帮助