java - Firebase 未触发成功或失败

标签 java android firebase firebase-authentication

我完全按照说明进行操作,事实上,我什至使用了 Android Studio 中 Firebase 帮助程序中的代码。我的问题就是这样,我的代码也没有发生登录或登录失败!我错过了什么?

 public void toSubscribe(View v) {
        Log.d("OK", "this part first");


        String strUsername, strPassword;
        strUsername = ((EditText) findViewById(R.id.username)).getText().toString();
        strPassword = ((EditText) findViewById(R.id.password)).getText().toString();


        if (strUsername.matches("")) {
            Toast.makeText(MainActivity.this, "You did not enter a username.", Toast.LENGTH_SHORT).show();
            return;
        }

        if (strPassword.matches("")) {
            Toast.makeText(MainActivity.this, "You did not enter a password.", Toast.LENGTH_SHORT).show();
            return;
        }



        mAuth.signInWithEmailAndPassword(strUsername, strPassword)
                .addOnCompleteListener(MainActivity.this, new OnCompleteListener<AuthResult>() {
                    @Override
                    public void onComplete(@NonNull Task<AuthResult> task) {
                        Log.d("TAG", "signInWithEmail: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.w("TAG", "signInWithEmail", task.getException());
                            Toast.makeText(MainActivity.this, "Authentication failed.",
                                    Toast.LENGTH_SHORT).show();
                        }
                    }
                });


    }

没什么可说的...我尝试使用新的 JSON 文件,但它仍然不起作用。我在 Google 上搜索了很多东西,但没有任何效果。

最佳答案

请检查以下内容:

1-您从 firebase 控制台正确安装并添加 Gson 文件

2-您从 Firebase 控制台启用 Firebase 身份验证

3-您的mAuth已正确初始化

关于java - Firebase 未触发成功或失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51993578/

相关文章:

java - JavaPoet 的泛型类

iphone - 手机开发: interact with the call?

android - 进程已完成,退出代码为 139

android - 如何使用 firebase 查询过滤 android listview 项目?

android - 无法解析 : com. firebase :fire-client-android:2. 4.2

javascript - 从 firebase 检索分割数据

java - 从java项目中的资源文件夹中获取所有文件名

java - Android 版 Google 登录无法正常工作,并出现安全警告

java - 我在 ArrayList 中有一堆单词(字符串?),我想知道是否可以找到每个元素的大小?

安卓多点触控干扰