在Firebase中注册用户时遇到问题

时间:2019-05-19 17:36:48

标签: android firebase firebase-authentication

我已经成功连接到firebase,并添加了所有必需的依赖项,但是我无法向其中注册用户。我在图中编写的代码也提供了gradle依赖项列表请检查我要去哪里错了

The code I've written

我已经在firebase中启用了电子邮件和密码验证,但是它不起作用。

这是我的依赖项列表。

 dependencies 
 {
   implementation fileTree(dir: 'libs', include: ['*.jar'])
   implementation 'com.android.support:support-v4:28.0.0'
   implementation 'com.google.firebase:firebase-core:16.0.9'
   implementation 'com.android.support:design:28.0.0'
   implementation 'com.google.firebase:firebase-database:16.0.1'
   implementation 'com.google.firebase:firebase-auth:17.0.0'
   implementation 'com.android.support:cardview-v7:28.0.0'
   implementation 'com.rengwuxian.materialedittext:library:2.1.4'
   implementation 'com.android.support.constraint:constraint-layout:1.1.3'
   testImplementation 'junit:junit:4.12'
   androidTestImplementation 'com.android.support.test:runner:1.0.2'
   androidTestImplementation 'com.android.support.test.espresso:espresso- 
   core:3.0.2'
 }

apply plugin: 'com.google.gms.google-services'

1 个答案:

答案 0 :(得分:0)

在社区帮助您解决问题之前,您需要提供更多信息。

要获取更多信息,我建议注销并共享该异常。在代码的else {}块中添加以下行:

Log.w(TAG, "createUserWithEmail:failure", task.getException());

看起来像这样(我无法复制粘贴您的代码,因为它是一个图像-将您的代码作为文本共享在问题中总是有帮助的,以便其他人可以复制和更正它)

 mAuth.createUserWithEmailAndPassword(email, password)
                .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
                    @Override
                    public void onComplete(@NonNull Task<AuthResult> task) {
                        if (task.isSuccessful()) {
                            // your code here
                        } else {
                            //your toast here                               
                Log.w(TAG,"createUserWithEmail:failure",task.getException());
                        }

已注销的错误可以在Android Studio底部的Logcat部分中找到:

enter image description here

谢谢