https://kotlinlang.org logo
#gradle
Title
# gradle
c

CLOVIS

03/18/2023, 1:27 PM
How can I specify a BOM in a multiplatform project?
Copy code
kotlin {
    jvm()
    android()

    sourceSets {
        val androidMain by getting {
            dependencies {
                implementation(platform(libs.androidx.compose.bom)) // Unresolved reference: platform
                implementation(libs.androidx.compose.material3)
            }
        }
    }
}
either don't use version catalog or switch to the top-level dependencies block
e.g.
Copy code
dependencies {
    "androidMainImplementation"(platform(...))
}
c

CLOVIS

03/18/2023, 1:31 PM
I just migrated to the version catalogs 😅
I'll use the top-level for just that dependency then, and migrate it when it's fixed
a

Adam S

03/18/2023, 1:32 PM
could you try this?
Copy code
implementation(project.dependencies.platform(libs.androidx.compose.bom))
c

CLOVIS

03/18/2023, 1:33 PM
@Adam S it compiles
I get
e: java.lang.Error: Something went wrong while checking for version compatibility between the Compose Compiler and the Kotlin Compiler.  It is possible that the versions are incompatible.
though (did not touch the versions)
e

ephemient

03/18/2023, 1:35 PM
you can check what it resolved to but I don't think that works currently. ideally it should, though
c

CLOVIS

03/18/2023, 1:36 PM
How can I check?
I get the same message with the top-level dependencies block
e

ephemient

03/18/2023, 1:38 PM
Copy code
./gradlew dependencies --configuration androidMainCompileClasspath
and see if the bom constraints appear
c

CLOVIS

03/18/2023, 1:40 PM
Configuration 'androidMainCompileClasspath' not found in configuration container.
🤔
Ah, I'm on Kotlin 1.7.20 and that was renamed in 1.8.0, right?
e

ephemient

03/18/2023, 1:42 PM
oh. then try a top-level
Copy code
dependencies {
    implementation(platform(...))
c

CLOVIS

03/18/2023, 1:42 PM
Copy code
releaseCompileClasspath - Resolved configuration for compilation for variant: release
+--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.20
|    +--- org.jetbrains.kotlin:kotlin-stdlib:1.7.20
|    |    \--- org.jetbrains:annotations:13.0
|    \--- org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.20
|         \--- org.jetbrains.kotlin:kotlin-stdlib:1.7.20 (*)
+--- androidx.compose:compose-bom:2023.01.00
|    +--- androidx.compose.material3:material3:1.0.1 (c)
|    +--- androidx.compose.material3:material3-window-size-class:1.0.1 (c)
|    +--- androidx.compose.foundation:foundation:1.3.1 (c)
|    +--- androidx.compose.material:material-icons-core:1.3.1 (c)
|    +--- androidx.compose.material:material-ripple:1.3.1 (c)
|    +--- androidx.compose.runtime:runtime:1.3.3 (c)
|    +--- androidx.compose.ui:ui:1.3.3 (c)
|    +--- androidx.compose.ui:ui-graphics:1.3.3 (c)
|    +--- androidx.compose.ui:ui-text:1.3.3 (c)
|    +--- androidx.compose.ui:ui-unit:1.3.3 (c)
|    +--- androidx.compose.animation:animation:1.3.3 (c)
|    +--- androidx.compose.runtime:runtime-saveable:1.3.3 (c)
|    +--- androidx.compose.ui:ui-geometry:1.3.3 (c)
|    +--- androidx.compose.animation:animation-core:1.3.3 (c)
|    \--- androidx.compose.foundation:foundation-layout:1.3.1 (c)
I'll be migrating to Kotlin 1.8.0 in the coming week or so
e

ephemient

03/18/2023, 1:42 PM
well that looks like a bom applied
c

CLOVIS

03/18/2023, 1:43 PM
Should I just ignore the compatibility warning then? (how?)
e

ephemient

03/18/2023, 1:44 PM
oh now that I check the message you posted
that has nothing to do with the bom
a

Adam S

03/18/2023, 1:48 PM
do you know which version of the 'Compose Compiler' your project has? I can't see it under the compile classpath, but maybe I've missed it. According to this https://developer.android.com/jetpack/androidx/releases/compose-kotlin it should be 1.3.2 (since you're using Kotlin 1.7.20), but possibly the warning is being triggered before the version has been resolved...?
c

CLOVIS

03/18/2023, 1:50 PM
I have the
compose-jb
plugin 1.2.1, if that helps
252 Views