使用firebase无法使用电子邮件和密码创建用户

时间:2017-09-24 05:26:30

标签: android firebase-authentication

我正在使用firebase身份验证来创建用户。但我收到注册错误。 firebase控制台中还启用了电子邮件/密码登录方法。我还在项目中添加了google-json文件,并在清单文件中添加了Internet权限。我的其他项目的身份验证工作正常,我对所有项目都执行了相同的步骤。但仍然得到这个错误。我无法弄清楚这个项目有什么问题。这是我的代码

 public class Registration extends AppCompatActivity implements View.OnClickListener {

//defining view objects
private EditText editTextEmail;
private EditText editTextPassword;
private Button buttonSignup;
private ProgressDialog progressDialog;


//defining firebaseauth object
private FirebaseAuth firebaseAuth;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_registration);

    //initializing firebase auth object
    firebaseAuth = FirebaseAuth.getInstance();

    //initializing views
    editTextEmail = (EditText) findViewById(R.id.ml);
    editTextPassword = (EditText) findViewById(R.id.ps);

    buttonSignup = (Button) findViewById(R.id.Reg);

    progressDialog = new ProgressDialog(this);

    //attaching listener to button
    buttonSignup.setOnClickListener(this);
}

private void registerUser(){

    //getting email and password from edit texts
    String email = editTextEmail.getText().toString().trim();
    String password  = editTextPassword.getText().toString().trim();

    //checking if email and passwords are empty
    if(TextUtils.isEmpty(email)){
        Toast.makeText(this,"Please enter email",Toast.LENGTH_LONG).show();
        return;
    }

    if(TextUtils.isEmpty(password)){
        Toast.makeText(this,"Please enter password",Toast.LENGTH_LONG).show();
        return;
    }

    //if the email and password are not empty
    //displaying a progress dialog

    progressDialog.setMessage("Registering Please Wait...");
    progressDialog.show();

    //creating a new user
    firebaseAuth.createUserWithEmailAndPassword(email, password)
            .addOnCompleteListener(Registration.this, new OnCompleteListener<AuthResult>() {
                @Override
                public void onComplete(@NonNull Task<AuthResult> task) {
                    //checking if success
                    if(task.isSuccessful()){
                        //display some message here
                        Toast.makeText(Registration.this,"Successfully registered",Toast.LENGTH_LONG).show();
                        Intent intent = new Intent(Registration.this, login.class);
                        startActivity(intent);
                    }else{
                        //display some message here
                        Toast.makeText(Registration.this,"Registration Error",Toast.LENGTH_LONG).show();
                    }
                    progressDialog.dismiss();
                }
            });

}

@Override
public void onClick(View view) {
    //calling register method on click
    registerUser();

}
}

logcat的:

09-24 10:40:27.229 28354-28354/com.example.devyug.userinterface E/ViewRootImpl: sendUserActionEvent() mView == null
 09-24 10:40:36.709 28354-28387/com.example.devyug.userinterface W/DynamiteModule: Local module descriptor class for com.google.firebase.auth not found.
 09-24 10:40:46.609 28354-28397/com.example.devyug.userinterface V/FA: Recording user engagement, ms: 31917
 09-24 10:40:46.619 28354-28397/com.example.devyug.userinterface V/FA: Using measurement service
 09-24 10:40:46.619 28354-28397/com.example.devyug.userinterface V/FA: Connecting to remote service
 09-24 10:40:46.669 28354-28397/com.example.devyug.userinterface D/dalvikvm: GC_FOR_ALLOC freed 1182K, 17% free 11541K/13880K, paused 26ms, total 47ms

我是初学者。

0 个答案:

没有答案