Firebase电子邮件/密码身份验证从未完成

时间:2018-12-24 16:09:41

标签: android firebase firebase-authentication

我在Android应用中实现了Firebase提供的电子邮件/密码登录方法。运行正常。但是今天由于某些我不知道的原因而无法使用。我没有更改与登录活动有关的任何代码,也没有更改Firebase控制台中的设置。

enter image description here

private void signIn(String email, String password) {
    Log.d(TAG, "signIn:" + email);
    if (!validateForm()) {
        return;
    }

    showProgressDialog();

    // [START sign_in_with_email]
    firebaseAuth.signInWithEmailAndPassword(email, password)
            .addOnCompleteListener(this, task -> {
                if (task.isSuccessful()) {
                    // Sign in success, update UI with the signed-in user's information
                    Log.d(TAG, "signInWithEmail:success");
                    FirebaseUser user = firebaseAuth.getCurrentUser();
                    updateUI(user);
                } else {
                    // If sign in fails, display a message to the user.
                    Log.w(TAG, "signInWithEmail:failure", task.getException());
                    Toast.makeText(LoginActivity.this, "Authentication failed.",
                            Toast.LENGTH_SHORT).show();
                }

                hideProgressDialog();
            });
    // [END sign_in_with_email]
}

在Logcat中,它表明程序确实达到了登录方法,但是以某种方式未完成身份验证过程(日志从不显示signInWithEmail:success或signInWithEmail:failure)。

enter image description here

我确实尝试了其他解决方案,例如将addOnCompleteListener更改为addOnSuccessListener,但没有任何更改。 Firebase服务当前无法正常工作吗?还是我的代码有问题?我完全迷失了。感谢您想分享的任何想法。

4 个答案:

答案 0 :(得分:0)

您注销了吗? 尝试先注销,然后它将登录。

尝试在onCreate方法中进行firebaseAuth.signOut()。 可能有帮助。

答案 1 :(得分:0)

我设法通过使用x86_64 SDK创建新的模拟器,使其再次工作。我认为这与this questionthis question

有关

答案 2 :(得分:0)

但是此日志引用的是方法(SignIn),而不是firebaseAuth方法,请从“工具”->“ Firebase”->“身份验证”->“连接到Firebase(如果未连接)”中检查您与Firebase的连接

答案 3 :(得分:0)

我还有另一个任务FirebaseAuth.getInstance()。currentUser.getIdToken(true)。它从未完成,因为我从主线程调用了它。当我从后台线程调用时-它完成了。