Моя настройка:
- Версия Kotlin: 2.0.0 (или ее версия)
- Версия Gradle: 8.x
- Проект: Kotlin Multiplatform (Compose Multiplatform)
Код: Выделить всё
FirebaseAuthDataSource.ktKotlin
Код: Выделить всё
interface AuthRemoteRepository {
suspend fun login(email: String, password: String): Result
}
class FirebaseAuthDataSource(
private val auth: FirebaseAuth
) : AuthRemoteRepository {
override suspend fun login(email: String, password: String): Result {
return try {
val authResult = auth.signInWithEmailAndPassword(email, password)
// Error here: Unresolved reference 'user'
val user = authResult.user ?: throw IllegalStateException("User is null")
// Error here: Unresolved reference 'await'
val tokenResult = user.getIdToken(true).await()
Result.success(UserToken(tokenResult.token ?: ""))
} catch (e: Exception) {
Result.failure(e)
}
}
}
Kotlin
Код: Выделить всё
kotlin {
androidTarget()
sourceSets {
val androidMain by getting {
dependencies {
implementation(platform("com.google.firebase:firebase-bom:33.10.0"))
implementation("com.google.firebase:firebase-auth")
// I tried adding this, but it still doesn't work
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-play-services:1.10.2")
}
}
}
}
- Добавление импорта kotlinx.coroutines.tasks.await, но IDE говорит, что его не существует.
- Очистка и пересборка проекта.
- Аннулирование кешей и Перезапуск Android Studio.
- Проверка внешних библиотек: kotlinx-coroutines-android есть, но я не могу найти Tasks.await в пути к классам.