使用Firebase-Auth时注册应用程序时如何解决错误

时间:2019-05-06 09:10:22

标签: java firebase firebase-authentication

当我在使用firebase-auth的应用程序中唱歌时出现错误。这段代码以前一直在工作,但是现在我从firebase收到了一个错误,说明不多。

我曾尝试使用其他android模拟器,甚至使用自己的手机,但每次都失败。

这是我用来在数据库中注册人员的OnClickListener的代码。

registerButton.setOnClickListener( // the back-end of the register button
                new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        if (editTextName == null || editTextName.getText().toString().trim().isEmpty()){
                            nameLayout.setError("Name is required.");
                            editTextName.requestFocus();
                            return; // check if name is empty or not
                        }
                        if (editTextEmail  == null || editTextEmail.getText().toString().trim().isEmpty()){
                            emailLayout.setError("Email is required");
                            return; // check if email is empty or not
                        }

                        if (editTextPassword == null || editTextPassword.getText().toString().trim().isEmpty()){
                            passwordLayout.setError("Password is required.");
                            editTextPassword.requestFocus();
                            return; // check if password is empty or not
                        }
                        if (!editTextPassword.getText().toString().trim().matches(editTextPasswordConfirmation.getText().toString().trim())){
                            passwordLayout.setError("Passwords must match");
                            editTextPasswordConfirmation.requestFocus();
                            return; // check if password is the same as password confirmation
                        }
                        if (!Patterns.EMAIL_ADDRESS.matcher(editTextEmail.getText().toString().trim()).matches()){
                            editTextEmail.setError("Enter a valid email.");
                            editTextEmail.requestFocus();
                            return; // check if email is a real email address
                        }
                        if (editTextPassword.getText().toString().trim().length() < 6){
                            passwordLayout.setError("Your password should be at least 6 characters long.");
                            editTextPassword.requestFocus(); // check if email is 6 characters or longer
                            return;
                        }

                        progressBar.setVisibility(View.VISIBLE);

                        mAuth.createUserWithEmailAndPassword(editTextEmail.getText().toString().trim(), editTextPassword.getText().toString().trim()).addOnCompleteListener(new OnCompleteListener<AuthResult>() {
                            @Override
                            public void onComplete(@NonNull Task<AuthResult> task) {
                                if (task.isSuccessful()) { // send email and password to authentication database
                                    Toast.makeText(Register.this, "Register Successful.", Toast.LENGTH_SHORT).show(); // show message that register was complete
                                    setUserInDatabase(); // send name, UID, Role and email to realtime database
                                    emptyInputEditText(); //empty the input fields

                                }

                                progressBar.setVisibility(View.INVISIBLE);




                            }
                        });

                    }
                }
        );

我得到的输出只是logcat中的一行:

W/BiChannelGoogleApi: [FirebaseAuth: ] getGoogleApiForMethod() returned Gms: com.google.firebase.auth.api.internal.zzam@c2bfc0a

是否有人以前曾收到此错误并已找到解决方案?在互联网上,我发现我应该更新自己尝试的Google Play服务。而且我正在android API 28(这是android的最新版本)上使用刚刚制作的android模拟器。

0 个答案:

没有答案