I'm using Kotlin and calling a Firebase Auth API:
private fun loginUser() {
email = etEmail?.text.toString()
password = etPassword?.text.toString()
mAuth!!.createUserWithEmailAndPassword(email!!, password!!)
.addOnCompleteListener(this) { task ->
if (task.isSuccessful) {
// Sign in success, update UI with the signed-in user's information
println("createUserWithEmail:success")
val user = mAuth?.currentUser
updateUI()
} else {
// If sign in fails, display a message to the user.
Log.w("TAG", "createUserWithEmail:failure", task.exception)
println("Authentication failed.")
updateUI()
}
}
}
The .addOnCompleteListener(this) line is showing these problems:
None of the following functions can be called with the arguments supplied:
public open fun addOnCompleteListener(p0: Activity, p1: OnCompleteListener<AuthResult!>): Task<AuthResult!> defined in com.google.android.gms.tasks.Task
public open fun addOnCompleteListener(p0: Executor, p1: OnCompleteListener<AuthResult!>): Task<AuthResult!> defined in com.google.android.gms.tasks.Task
I'm doing this in a Fragmet. I've done this in an Activity before. I compare the code and setup with that one and it is all the same. Not sure why it is showing the error.
My Firebase db has login with email and password enabled.
My AndroidManifest.xml file has Internet enabled.
My app is setup correctly with Firebase.
Not sure what I'm missing.
Thanks for any help.