Home > Blockchain >  Firebase.auth is a unresolved reference. How can I fix it?
Firebase.auth is a unresolved reference. How can I fix it?

Time:10-04

I'll try to follow the Firebase Login tutorial, but these lines break my code because auth is an unresolved reference. How can I fix it?

class LoginActivity : AppCompatActivity() {
    private lateinit var auth: FirebaseAuth
        override fun onCreate(savedInstanceState: Bundle?) {
           auth = Firebase.auth
    }
}

CodePudding user response:

You need to add this line:

import com.google.firebase.auth.FirebaseAuth;

And correct this line:

 auth = Firebase.auth

to

 auth = FirebaseAuth.getInstance()

CodePudding user response:

You're getting the following behavior:

Firebase.auth is a unresolved reference

Most likely because of two main reasons. The first one would be because you didn't add the proper dependencies. By the time I'm answering this question, you should use:

implementation platform("com.google.firebase:firebase-bom:30.5.0")
implementation "com.google.firebase:firebase-auth-ktx"
//                                                           
  • Related