firebase-kotlin-sdk icon indicating copy to clipboard operation
firebase-kotlin-sdk copied to clipboard

"Could not find com.google.firebase:firebase-common" when build command is executed

Open GerardPaligot opened this issue 2 years ago • 4 comments

I integrated firebase-app, firebase-firestore and firebase-auth in my KMM project but when I launch a build command, I got this error:

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':sample-app:lintReportDebug'.
> Could not resolve all task dependencies for configuration ':sample-app:debugAndroidTestCompileClasspath'.
   > Could not find com.google.firebase:firebase-common:.
     Required by:
         project :sample-app > project :openfeedback-m2 > project :openfeedback > dev.gitlive:firebase-app:1.6.2 > dev.gitlive:firebase-app-android-debug:1.6.2

The content of my build.gradle.kts is pretty simple:

    sourceSets {
        val commonMain by getting {
            dependencies {
                api(libs.kotlin.coroutines.core)
                api("org.jetbrains.kotlinx:kotlinx-serialization-json:1.4.1")
                api("dev.gitlive:firebase-app:1.6.2")
                implementation("dev.gitlive:firebase-firestore:1.6.2")
                implementation("dev.gitlive:firebase-auth:1.6.2")
                implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.4.0")
            }
        }
        val androidMain by getting
        if (OperatingSystem.current().isMacOsX) {
            val iosX64Main by getting
            val iosArm64Main by getting
            val iosSimulatorArm64Main by getting
            val iosMain by creating {
                dependsOn(commonMain)
                iosX64Main.dependsOn(this)
                iosArm64Main.dependsOn(this)
                iosSimulatorArm64Main.dependsOn(this)
            }
        }
    }

If you want to have more context, you can find my branch with firebase-kotlin-sdk configured here: https://github.com/GerardPaligot/openfeedback-android-sdk/tree/refactor/ios/firestore

Thanks in advance!

GerardPaligot avatar Mar 12 '23 21:03 GerardPaligot

Does it work if you add to your common main

implementation("dev.gitlive:firebase-common:1.6.2")

Reedyuk avatar Mar 14 '23 16:03 Reedyuk

No, if I add this dependency, I got this error:

* What went wrong:
Could not determine the dependencies of task ':sample-app:lintReportDebug'.
> Could not resolve all task dependencies for configuration ':sample-app:debugAndroidTestCompileClasspath'.
   > Could not find com.google.firebase:firebase-common:.
     Required by:
         project :sample-app > project :openfeedback-m2 > project :openfeedback > dev.gitlive:firebase-app:1.6.2 > dev.gitlive:firebase-app-android-debug:1.6.2
         project :sample-app > project :openfeedback-m2 > project :openfeedback > dev.gitlive:firebase-common:1.6.2 > dev.gitlive:firebase-common-android-debug:1.6.2

So pretty the same but with dev.gitlive:firebase-common too. But adding the firebase dependency in the Android target dependencies resolve this issue:

        val androidMain by getting {
            dependencies {
                api("com.google.firebase:firebase-common:20.3.1")
            }
        }

However, I think it is more a workaround than a final solution.

GerardPaligot avatar Mar 15 '23 19:03 GerardPaligot

Hi, I finish to publish an article about this https://medium.com/@carlosgub/how-to-implement-firebase-firestore-in-kotlin-multiplatform-mobile-with-compose-multiplatform-32b66cdba9f7

carlosgub avatar Sep 22 '23 04:09 carlosgub