Android - Firebase快速入门电子邮件/密码验证演示不起作用 [英] Android - Firebase Quickstart Email/Password Auth demo doesn't work

查看:303
本文介绍了Android - Firebase快速入门电子邮件/密码验证演示不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,这里有几个类似的问题,但是他们没有一个能为我提供解决方案。

我正在使用从Github下载的快速入门演示。今天下载。我没有在演示代码中改变任何东西。

一些常见的错误(从我读到的)我已经解决:


  • 我已经在Firebase控制台中创建了使用
    可下载的json文件(使用软件包名称创建)的项目。我提供了
    我的SHA1指纹。

  • 检查电子邮件/密码登录方法。

  • 服务和Google Repository更新和安装(来自Android
    Studio SDK管理器)
  • 在我的设备上,Google Play服务是版本9.4.52如果我在Firebase控制台中启用匿名登录选项,则可以匿名登录演示应用程序。但电子邮件/密码将无法正常工作。

    编辑:不知道我是否正确地做了这件事,但是我在Logcat中得到了这些信息

      D / EmailPassword:createAccount:chris884@gmail.com 
    W / DynamiteModule:未找到com.google.firebase.auth的本地模块描述符类。
    W / ResourcesManager:资产路径/system/framework/com.android.media.remotedisplay.jar不存在或不包含任何资源。
    W / ResourcesManager:资产路径/system/framework/com.android.location.provider.jar不存在或不包含任何资源。
    D / EmailPassword:createUserWithEmail:onComplete:false


    解决方案

    logcat 输出显示创建用户帐户失败。 文档表明这可能发生,原因如下:




    • 密码不够强(少于6个字符)

    • 电子邮件地址格式不正确

    • 已存在具有给定电子邮件地址的帐户



    createUserWithEmailAndPassword()的完成监听器中添加一个 Log 失败的原因是:

      @Override 
    public void onComplete(@NonNull Task< AuthResult> task){
    Log.d(TAG,createUserWithEmail:onComplete:+ task.isSuccessful());

    //如果登录失败,则向用户显示一条消息。如果登录成功
    //将通知auth状态侦听器,并且处理
    //登录用户的逻辑可以在侦听器中处理。
    if(!task.isSuccessful()){
    Log.d(TAG,onComplete:Failed =+ task.getException()。getMessage()); // Add this

    Toast.makeText(EmailPasswordActivity.this,R.string.auth_failed,
    Toast.LENGTH_SHORT).show();
    }

    // [START_EXCLUDE]
    hideProgressDialog();
    // [END_EXCLUDE]
    }


    So, there are a couple similar questions on here, but none of them have a working solution for me.

    I am using the Quickstart demo downloaded from Github. Downloaded today. I've changed nothing in the demo code.

    Some common mistakes (from what I've read) that I've addressed:

    • I have the project created in the Firebase Console with the downloadable json file (created with package name). I have provided my SHA1 fingerprint.

    • Email/Password sign-in method is checked.

    • I have Google Play Services and Google Repository updated and installed (from the Android Studio SDK manager)

    • On my device Google Play Services is version 9.4.52

    If I turn on the Anonymous sign-in option in the Firebase Console, I'm able to successfully Anonymously sign in on the demo app. But Email/Password will not work.

    Edit: Not sure if I'm doing this right, but I got these in Logcat

    D/EmailPassword: createAccount:chris884@gmail.com
     W/DynamiteModule: Local module descriptor class for com.google.firebase.auth not found.
     W/ResourcesManager: Asset path '/system/framework/com.android.media.remotedisplay.jar' does not exist or contains no resources.
     W/ResourcesManager: Asset path '/system/framework/com.android.location.provider.jar' does not exist or contains no resources.
     D/EmailPassword: createUserWithEmail:onComplete:false
    

    解决方案

    The logcat output shows that the creation of the user account is failing. The documentation indicates this can happen for these reasons:

    • the password is not strong enough (less than 6 characters)
    • the email address is malformed
    • there already exists an account with the given email address

    Add a Log statement to the completion listener for createUserWithEmailAndPassword() to see what the failure reason is:

    @Override
    public void onComplete(@NonNull Task<AuthResult> task) {
        Log.d(TAG, "createUserWithEmail:onComplete:" + task.isSuccessful());
    
        // If sign in fails, display a message to the user. If sign in succeeds
        // the auth state listener will be notified and logic to handle the
        // signed in user can be handled in the listener.
        if (!task.isSuccessful()) {
            Log.d(TAG, "onComplete: Failed=" + task.getException().getMessage()); //ADD THIS
    
            Toast.makeText(EmailPasswordActivity.this, R.string.auth_failed,
                    Toast.LENGTH_SHORT).show();
        }
    
        // [START_EXCLUDE]
        hideProgressDialog();
        // [END_EXCLUDE]
    }
    

    这篇关于Android - Firebase快速入门电子邮件/密码验证演示不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆