[英]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.