首页 > 解决方案 > Firebase 中的用户注册问题

问题描述

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

我写的代码

我已经在 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'

标签: androidfirebasefirebase-authentication

解决方案


您需要提供更多信息,然后社区才能帮助您解决问题。

要获取更多信息,我建议注销异常并共享它。在代码的 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 部分找到:

在此处输入图像描述

谢谢


推荐阅读