Hi guys, i’m converting my existing Android app in...
# multiplatform
l
Hi guys, i’m converting my existing Android app into KMM and i’m having really hard time configuring gradle. The specific issue i’m hitting now is with adding Firebase Libraries:
Copy code
val commonMain by getting {
    dependencies {
        // Firebase: Import the BoM for the Firebase platform
        implementation(project.dependencies.platform("com.google.firebase:firebase-bom:31.0.2"))
        // Firebase: Cloud Firestore library BoM doesn't specify versions in Firebase library dependencies
        implementation("com.google.firebase:firebase-firestore-ktx")
        // Firebase: crashlytics
        implementation("com.google.firebase:firebase-crashlytics")

        // Firebase: Authentication
        implementation("com.google.firebase:firebase-auth-ktx")
        // Coroutines support libraries for Kotlin - required by firebase-analytics
        implementation("org.jetbrains.kotlinx:kotlinx-coroutines-play-services:1.6.4")

        // TODO this is platform specific?
        //implementation("com.google.firebase:firebase-analytics-ktx")
    }
}
Error:
Copy code
:shared:iosArm64Main: Could not resolve org.jetbrains.kotlinx:kotlinx-coroutines-play-services:1.6.4.
Required by:
    project :shared > com.google.firebase:firebase-firestore-ktx:24.4.0 > com.google.firebase:firebase-common-ktx:20.2.0

Possible solution:
 - Declare repository providing the artifact, see the documentation at <https://docs.gradle.org/current/userguide/declaring_repositories.html>
For some reason, it doesn’t like the ff library:
Copy code
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-play-services:1.6.4")
am i missing some kind of plugin?
j
That library isn't multiplatform. It only supports Android, as it requires Google Play Services. With Kotlin Multiplatform, shared code has to utilize pure Kotlin APIs or libraries that support the platform targets you require support for.
You might check out a library such as https://github.com/gitliveapp/firebase-kotlin-sdk/ for Firebase KMP support.
j
When using a library for a specific platform you have to add it to the dependencies of the proper target. Since the play services lib is specific to android, you must put in the dependencies of the android target, not in the common ones.
l
That makes sense. Thank you so much 🙏
833 Views