Android Firebase Logging In Issue

so I am having trouble logging in to my android studio application in Google Firebase. Everytime I login with the right credentials it gives me this error in the logcat:

2024-04-24 11:22:40.121 21671-21711 FirebaseAuth com.example. D Notifying auth state listeners about user ( seitY2BtflUvO1VqHdcBCPcLHlk1 ).

If anyone can help me get it to work properly I would greatly appreciate it, below are the relevant codes I have:
(sorry for all the code I am really want to use Firebase for future project so I just want to know what I am doing wrong


//Application.kt

package com.example.homework3

import android.app.Application
import com.google.firebase.firestore.ktx.firestore
import com.google.firebase.ktx.Firebase

class MyApp : Application() {
    companion object {
        lateinit var instance: MyApp
        lateinit var salesRepo: SalesRepository
    }

    override fun onCreate() {
        super.onCreate()
        instance = this
        salesRepo = SalesRepository(Firebase.firestore)
    }
} 
//LoginScreenViewModel.kt

package com.example.homework3

import android.util.Log
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.google.firebase.auth.FirebaseAuth
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.tasks.await
import kotlinx.coroutines.withContext

class LoginScreenViewModel : ViewModel() {
    private val firebaseAuth = FirebaseAuth.getInstance()

    fun loginFirebase(email: String, password: String, successfulLoginHandler: () -> Unit, unsuccessfulLoginHandler: () -> Unit) {
        viewModelScope.launch(Dispatchers.IO) {
            try {
                firebaseAuth.signInWithEmailAndPassword(email, password).await()
                withContext(Dispatchers.Main) {
                    successfulLoginHandler()
                }
            } catch (e: Exception) {
                Log.e("LoginException", "Login failed: ${e.message}")
                withContext(Dispatchers.Main) {
                    unsuccessfulLoginHandler()
                }
            }
        }
    }
}



//LoginScreen.kt

package com.example.homework3

import android.widget.Toast
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Button
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.material3.TextField
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.input.PasswordVisualTransformation
import androidx.compose.ui.unit.dp
import androidx.navigation.NavController
import androidx.lifecycle.viewmodel.compose.viewModel
import com.google.firebase.auth.FirebaseAuth

@Composable
fun LoginScreen(navController: NavController, viewModel: LoginScreenViewModel = viewModel()) {
    val firebaseAuth = FirebaseAuth.getInstance()
    val currentUser = firebaseAuth.currentUser
    val initialEmail = currentUser?.email ?: ""
    var email by remember { mutableStateOf(initialEmail) }
    var password by remember { mutableStateOf("") }
    val context = LocalContext.current

    Box(
        modifier = Modifier
            .fillMaxSize()
            .padding(top = 15.dp),
        contentAlignment = Alignment.TopCenter
    ) {
        Surface(
            modifier = Modifier
                .fillMaxWidth()
                .padding(horizontal = 24.dp),
            shadowElevation = 8.dp
        ) {
            Column(
                modifier = Modifier.padding(all = 15.dp),
                verticalArrangement = Arrangement.spacedBy(10.dp)
            ) {
                Text(
                    text = "Login",
                    style = MaterialTheme.typography.headlineLarge.copy(fontWeight = FontWeight.Bold),
                    modifier = Modifier.align(Alignment.Start),
                    color = MaterialTheme.colorScheme.primary
                )
                TextField(
                    value = email,
                    onValueChange = { email = it },
                    label = { Text("Email") }
                )
                TextField(
                    value = password,
                    onValueChange = { password = it },
                    label = { Text("Password") },
                    visualTransformation = PasswordVisualTransformation()
                )
                Button(
                    onClick = {
                        viewModel.loginFirebase(email, password, {
                            navController.navigate("salesList")  // Assuming "salesList" is your destination on successful login
                        }, {
                            Toast.makeText(context, "Login unsuccessful", Toast.LENGTH_SHORT).show()
                        })
                    }
                ) {
                    Text("Log In")
                }
            }
        }
    }
}





//Sale.kt

package com.example.homework3

import androidx.room.Entity
import androidx.room.PrimaryKey

@Entity(tableName = "sale")
data class Sale(
    @PrimaryKey val name: String = "NAME EMPTY",
    val amount: Double = 0.0
)




//SalesDao.kt

package com.example.homework3

import androidx.room.Dao
import androidx.room.Insert
import androidx.room.Query

@Dao
interface SaleDao {
    @Insert
    suspend fun insertSale(sale: Sale)

    @Query("SELECT * FROM sale")
    suspend fun getAllSales(): List<Sale>
}





//SalesRepository.kt

package com.example.homework3

import com.google.firebase.firestore.FirebaseFirestore
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.tasks.await

class SalesRepository(private val db: FirebaseFirestore) {

    suspend fun addSale(sale: Sale) {
        db.collection("Hwk4Sales").document().set(mapOf(
            "name" to sale.name,
            "amount" to sale.amount.toString()
        )).await()
    }

    fun getAllSales(): Flow<List<Sale>> = flow {
        val snapshot = db.collection("Hwk4Sales").get().await()
        val sales = snapshot.documents.map { doc ->
            Sale(
                name = doc.getString("name") ?: "NAME EMPTY",
                amount = doc.getString("amount")?.toDouble() ?: 0.0
            )
        }
        emit(sales)
    }
}

I tried to use these rules in Firebase which im sure it is right:

rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if request.auth.uid != null;
}
}
}

and this was my Application.kt code before:





//Application.kt

package com.example.homework3

import android.app.Application
import com.google.firebase.FirebaseApp

class MyApp : Application() {
    companion object {
        lateinit var instance: MyApp
        lateinit var salesRepo: SalesRepository
            private set
    }

    override fun onCreate() {
        super.onCreate()
        instance = this

        // Check if Firebase has already been initialized
        if (FirebaseApp.getApps(this).isEmpty()) { 
        }

        salesRepo = SalesRepository()
    }

but the firebase is already initialized using my SHA1 key

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật