Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why do I get "Unresolved reference: platform" when using the firebase-bom dependency with KMM

When I attempt to add the Firebase-bom dependency using the following block in a Kotlin Multiplatform Mobile (KMM) project's shared module, the word platform appears in red error text and the Gradle build fails with "Unresolved reference: platform." How can I resolve this so it builds correctly?

        val androidMain by getting {
            dependencies {
                implementation(platform("com.google.firebase:firebase-bom:28.0.1"))
                implementation("com.google.firebase:firebase-analytics-ktx")
            }
        }
like image 511
colintheshots Avatar asked Jan 23 '26 07:01

colintheshots


1 Answers

The answer lies in KT-40489.

The platform() function used to import the Firebase Bill of Materials is not available in Kotlin Multiplatform plugin’s KotlinDependencyHandler but only in Gradle’s standard DependencyHandler. It also does not seem that a fix is coming soon. As a result, you need to specify Gradle's handler explicitly.

Here are two workarounds:

val androidMain by getting {
    dependencies {
        implementation(project.dependencies.platform("..."))
    }
}

OR

val androidMain by getting {
    dependencies {
        "jvmMainImplementation"(platform("...))
    }
}
like image 65
colintheshots Avatar answered Jan 25 '26 07:01

colintheshots



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!