Firebase Authentication is a powerful tool for managing users in Android apps using Kotlin. However, developers often face login issues when using FirebaseAuth — especially when debugging email/password authentication. In this guide, we will walk through how to solve the FirebaseAuth not logging in problem in Kotlin.
Common Causes FirebaseAuth Fails to Log In:
- Invalid or null email/password inputs
- FirebaseAuth not properly initialized
- Wrong rules in Firebase console
- Email not verified
- No internet connection
We will debug step-by-step with full source code examples split by class to make your app authentication work correctly.
1. Gradle Setup
Ensure your dependencies are correctly set:
// app/build.gradle implementation("com.google.firebase:firebase-auth-ktx:22.1.1")
Don’t forget to initialize Firebase in your Application class.
2. FirebaseAuthHelper.kt – Auth Utility Class
object FirebaseAuthHelper { private val auth: FirebaseAuth = FirebaseAuth.getInstance() fun loginUser(email: String, password: String, onSuccess: () -> Unit, onError: (String) -> Unit) { if (email.isBlank() || password.isBlank()) { onError("Email or Password must not be empty") return } auth.signInWithEmailAndPassword(email, password) .addOnCompleteListener { task -> if (task.isSuccessful) { val user = auth.currentUser if (user?.isEmailVerified == true) { onSuccess() } else { onError("Email not verified") } } else { onError(task.exception?.localizedMessage ?: "Login failed") } } } }
3. LoginActivity.kt – UI Logic
class LoginActivity : AppCompatActivity() { private lateinit var emailInput: EditText private lateinit var passwordInput: EditText private lateinit var loginButton: Button override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_login) emailInput = findViewById(R.id.emailEditText) passwordInput = findViewById(R.id.passwordEditText) loginButton = findViewById(R.id.loginButton) loginButton.setOnClickListener { val email = emailInput.text.toString().trim() val password = passwordInput.text.toString().trim() FirebaseAuthHelper.loginUser(email, password, onSuccess = { Toast.makeText(this, "Login Success", Toast.LENGTH_SHORT).show() startActivity(Intent(this, MainActivity::class.java)) finish() }, onError = { message -> Toast.makeText(this, message, Toast.LENGTH_LONG).show() } ) } } }
4. Firebase Console Check
Go to your Firebase Console > Authentication > Sign-in Method
- Make sure Email/Password is enabled
- Check Authentication Rules under Firestore or Realtime DB
- Ensure that user email is verified if required