FirebaseAuth неполная ссылка в Kotlin Multiplatform - PullRequest
0 голосов
/ 23 марта 2020

Я пытаюсь создать Аутентификацию Firebase, которая будет разделена между iOS и Android. Как изложено в документации Firebase, вот моя auth функция в Kotlin.

private fun doLogin() {
        val auth = FirebaseAuth.getInstance()

        auth.signInWithEmailAndPassword(email, password)
            .addOnCompleteListener(this) { task ->
                if (task.isSuccessful) {
                    // Sign in success, update UI with the signed-in user's information
                    val user = auth.currentUser
                    Toast.makeText(baseContext, "${onLoginSuccess()}!", Toast.LENGTH_SHORT).show()
                    val intent = Intent(this, HomeActivity::class.java)
                    startActivity(intent)
                } else {
                    // If sign in fails, display a message to the user.
                    Toast.makeText(baseContext, "${onLoginFail()}",
                        Toast.LENGTH_SHORT).show()
                }
            }
    }

Что я пытаюсь сделать сейчас, это реализовать это с помощью Kotlin MPP. Тем не менее, я получаю unresolved reference: FirebaseAuth всякий раз, когда пытаюсь импортировать Firebase.

Например, вот мой common.kt

import com.google.firebase.auth.FirebaseAuth

expect fun firebaseAuth(email: String, password: String): Boolean

fun doFirebaseAuth(): Boolean {
   // FireBase auth here
}

actual.kt

import com.google.firebase.auth.FirebaseAuth

actual fun firebaseAuth(email: String, password: String): Boolean {
    // do FirebaseAuth here
    return true
}

Вот мой build.gradle (app)

...
dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.core:core-ktx:1.2.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'com.google.firebase:firebase-analytics:17.2.2'
    implementation 'com.google.firebase:firebase-auth:19.2.0'
    implementation 'com.google.firebase:firebase-firestore:21.4.0'
    implementation project(':SharedCode')
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'

}

Есть ли способ реализовать это? Что я делаю не так, и что мне нужно, чтобы это исправить?

Спасибо!

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...