Hey! I am running into this error for Jetpack comp...
# compose
t
Hey! I am running into this error for Jetpack compose after upgrading Kotlin from 1.9.20 to 2.0.20. Would any one know why this is happing after the upgrade?
Copy code
java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/compose/ui/platform/ComposeView;
                                                                                                    	at androidx.activity.compose.ComponentActivityKt.setContent(ComponentActivity.kt:55)
                                                                                                    	at androidx.activity.compose.ComponentActivityKt.setContent$default(ComponentActivity.kt:51)
                                                                                                    	at .TestingActivity.onCreate(TestingActivity.kt:15)
                                                                                                    	at android.app.Activity.performCreate(Activity.java:8305)
                                                                                                    	at android.app.Activity.performCreate(Activity.java:8284)
                                                                                                    	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1417)
build.gradle
Copy code
plugins {
    id("com.android.library")
    id("org.jetbrains.kotlin.android")
    id("kotlin-parcelize")
    id("org.jetbrains.kotlin.plugin.compose") version "2.0.20"
}

dependencies {
    def composeBom = platform('androidx.compose:compose-bom:2024.10.01')
    implementation composeBom
    androidTestImplementation composeBom

    implementation 'androidx.compose.material3:material3'
    implementation 'androidx.compose.foundation:foundation'
    implementation 'androidx.compose.ui:ui-tooling-preview'
    implementation 'androidx.compose.runtime:runtime'
    implementation 'androidx.activity:activity-compose'
    debugImplementation 'androidx.compose.ui:ui-tooling'
}
p
You most likely are depending on other libraries that use compose and where compiled with a different compose version
Or you are also missing
compose-ui
dependency
Is usually these 4,
runtime
,
ui
,
foundation
,
material3
t
gotcha, I assumed
androidx.compose.material3:material3
would also contain compose-ui. But just tried adding
implementation 'androidx.compose.ui:ui'
and still getting the error. I have a couple other third party dependencies that may have compose coupled in there so maybe one of them have a different compose version. Ill try to see if that is the case. Thanks again!
👍 1