I swear I ran the app when I first downloaded the Kotlin Multiplatform Wizard template for android/ desktop/ iOs but now when I run it I just get the following error:
Exception in thread "main" java.lang.NoClassDefFoundError: androidx/collection/ScatterMapKt
at androidx.compose.runtime.collection.ScopeMap.<init>(ScopeMap.kt:26)
at androidx.compose.runtime.CompositionImpl.<init>(Composition.kt:479)
at androidx.compose.runtime.CompositionImpl.<init>(Composition.kt:434)
at androidx.compose.runtime.CompositionKt.Composition(Composition.kt:335)
at ...
Which when I google, or ask ai for help leads me to add a dependency on androidx.collection:collection:1.4.0
and that seems to lead to other dependencies on windows specific problems. All this leads me to believe that compose for desktop (which says it is beta) isn’t ready for prime-time.
Following several red herrings and diving down many rabbit holes, I finally find the mulitplatform “how to run” page. You have to create a special desktop run gradle target:
composeApp:desktopRun -DmainClass=MainKt --quiet
That works! YAY!!!
So lets recreate it in our KotlinMultiplatformTesting github repo. I added the above gradle command and still got my error, until I added the following line to the sourcesets in the composeApp/build.gradle.kts:
kotlin {
...
sourceSets {
val desktopMain by getting {
dependencies {
implementation(compose.desktop.currentOs)
}
}
Ok, that worked too, so we have some validation!
I’ve updated the github repo