简体   繁体   English

我无法登录。 即使我在Firebase中输入了电子邮件和密码,它仍会说错误日志记录

[英]I can't login. It keeps Saying Error Logging in eventhough I have entered the email and password as I input in Firebase

The Email/Password sign-in provider's status has always been "Enabled" since the start. 自启动以来,电子邮件/密码登录提供者的状态始终为“启用”。 but it's still giving me the same error. 但它仍然给我同样的错误。 Even from the Authentication in Firebase shows that 1. Connect your app to Firebase -> Connected (green check) 2. Add Firebase Authentication to your app -> Dependencies set up correctly (green check) 即使从Firebase中的身份验证显示1.将您的应用程序连接到Firebase->已连接(绿色选中)2.将Firebase身份验证添加到您的应用程序->正确设置了依赖项(绿色选中)

I have tried to login with email and password that I entered into the Firebase but I still can't login. 我已尝试使用输入Firebase的电子邮件和密码登录,但仍然无法登录。 It shows me Toast: 它向我显示了吐司:

Error Logging in :( 登录错误:(

I have been trying to find solutions from the internet. 我一直在尝试从互联网上找到解决方案。 This is my current code: 这是我当前的代码:

04-14 18:46:05.238 9631-9631/com.adrian.projectadrian E/Login Error: signInWithEmailAndPassword
    com.google.firebase.auth.FirebaseAuthException: The given sign-in provider is disabled for this Firebase project. Enable it in the Firebase console, under the sign-in method tab of the Auth section.
        at com.google.firebase.auth.api.internal.zzdr.zzb(Unknown Source)
        at com.google.firebase.auth.api.internal.zzey.zza(Unknown Source)
        at com.google.firebase.auth.api.internal.zzeo.zzc(Unknown Source)
        at com.google.firebase.auth.api.internal.zzeq.onFailure(Unknown Source)
        at com.google.firebase.auth.api.internal.zzdx.dispatchTransaction(Unknown Source)
        at com.google.android.gms.internal.firebase_auth.zza.onTransact(Unknown Source)
        at android.os.Binder.execTransact(Binder.java:453)
package com.adrian.projectadrian

import android.content.Intent
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import android.util.Log
import android.view.View
import android.widget.EditText
import android.widget.Toast
import com.google.android.gms.tasks.OnCompleteListener
import com.google.firebase.FirebaseApp
import com.google.firebase.auth.AuthResult
import com.google.firebase.auth.FirebaseAuth
import kotlinx.android.synthetic.main.activity_main.*

class MainActivity : AppCompatActivity() {
    var mAuth = FirebaseAuth.getInstance()

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        FirebaseApp.initializeApp(this)
        setContentView(R.layout.activity_main)

        login_btn.setOnClickListener(View.OnClickListener {
            login()
        })
    }

    private fun login() {
        val emailTxt = findViewById<View>(R.id.email) as EditText
        var email = emailTxt.text.toString()
        val passwordTxt = findViewById<View>(R.id.password) as EditText
        var password = passwordTxt.text.toString()
        if (!email.isEmpty() && !password.isEmpty()) {
            this.mAuth.signInWithEmailAndPassword(email, password)
                .addOnCompleteListener(this, OnCompleteListener<AuthResult> { task ->
                    if (task.isSuccessful) {
                        startActivity(Intent(this, home::class.java))
                        Toast.makeText(this, "Successfully Logged in :)", Toast.LENGTH_LONG).show()
                    } else {
                        Log.e("Login Error", "signInWithEmailAndPassword", task.getException())
                        Toast.makeText(this, "Error Logging in :(", Toast.LENGTH_SHORT).show()
                    }
                })

        } else {
            Toast.makeText(this, "Please fill up the Credentials :|", Toast.LENGTH_SHORT).show()
        }
    }
}

Expected Result is that it can direct me to home page. 预期结果是它可以将我定向到主页。

After your edit we can now see that this is the error message: 编辑之后,我们现在可以看到这是错误消息:

The given sign-in provider is disabled for this Firebase project. 该Firebase项目已禁用给定的登录提供程序。 Enable it in the Firebase console, under the sign-in method tab of the Auth section. 在Firebase控制台的“身份验证”部分的登录方法标签下启用该功能。

So you haven't enabled the provider that you're trying to sign in with. 因此,您尚未启用尝试登录的提供程序。 The solution is to go to the Firebase Authentication console and enable that provider. 解决方案是转到Firebase身份验证控制台并启用该提供程序。


Original response: 原始回复:

If a Task failed, it contains an exception with details about the failure. 如果Task失败,则它包含一个异常以及有关该失败的详细信息。 You should log that exception to find out why the sign-in fails. 您应该记录该异常,以查找登录失败的原因。

this.mAuth.signInWithEmailAndPassword(email, password)
    .addOnCompleteListener(this, OnCompleteListener<AuthResult> { task ->
        if (task.isSuccessful) {
            startActivity(Intent(this, home::class.java))
            Toast.makeText(this, "Successfully Logged in :)", Toast.LENGTH_LONG).show()
        } else {
            Log.e("Login Error", "signInWithEmailAndPassword", task.getException());
            Toast.makeText(this, "Error Logging in :(", Toast.LENGTH_SHORT).show()
        }
    })

With the above code you can find the exception in the logcat output of your app. 使用以上代码,您可以在应用的logcat输出中找到异常。

So what I did was download another 所以我要做的就是下载另一个

google-services.json

and replaced it to Dir 并将其替换为Dir

app

and change to this 并更改为此

    implementation 'com.google.firebase:firebase-auth:16.0.1'
    implementation 'com.google.firebase:firebase-core:16.0.1'

in my build.gradle (Module: app) and this solved my problem. 在我的build.gradle(模块:应用程序)中,这解决了我的问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我无法使用 Firebase 身份验证使用电子邮件和密码登录 - I can't login with Email & Password using Firebase Authentication 如何限制Firebase电子邮件登录中的错误密码尝试? - How can i limit the wrong password attempts in Firebase email login? 为什么即使我可以正常运行应用程序,FirebaseUI日志记录仍会断言A / FirebaseApp:Firebase API初始化失败? - Why FirebaseUI logging assert A/FirebaseApp: Firebase API initialization failure eventhough I can run the application normaly? 如何验证输入的密码是否与输入的电子邮件相关联? - How do I verify password entered is the password associated with entered email? 我有一个问题,如果我使用 firebase facebook 登录如何获取用户名或 email? - I have a question, if I used firebase facebook login how can get username or email? Firebase - 代码 10 错误谷歌登录。我也有相同项目的朋友无法登录,但我可以 - Firebase - code 10 error google sign in. My friend who also have same project can't login, but I can 为什么我无法将Firebase电子邮件密码登录链接到Google登录? - Why can't I link firebase email-password sign-in to google sign-in? 我的日食无法打开,我下载了一直提示错误日志的捆绑包 - My eclipse won't open, i download the bundle pack it keeps saying error log Firebase身份验证错误:我启用了电子邮件/密码选项 - Firebase Authentication Error: I Enabled the Email/Password option 登录活动-如果用户忘记密码,如何发送电子邮件给用户? - Login Activity - How can I send email to user if they forgot password?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM