https://kotlinlang.org logo
Title
k

K J

01/21/2021, 11:12 PM
I seem to be getting a
NoSuchMethodError
when trying to add Compose Desktop to my current project. I'm using Kotlin 1.4.30-RC (though this happens with 1.4.20 as well) and Compose Alpha
0.3.0-build141.
j

jim

01/21/2021, 11:16 PM
You need to ensure you are using the correct version of Kotlin that corresponds to the build of Compose you are using. If you are using the latest builds of Compose, I believe the corresponding Kotlin version is
1.4.21
k

K J

01/21/2021, 11:24 PM
Ah - seems like it's running with the 1.4.21 runtime but using 1.4.30-RC to compile (blah, Gradle). Why does this matter, is it a JNI thing?
j

jim

01/21/2021, 11:28 PM
It matters because the Compose Compiler needs to reach into the internals of the Kotlin Compiler in order to compile your code, and if the assumptions don't match, then undefined results will occur.
k

K J

01/21/2021, 11:38 PM
Gotcha. Yeah, I did uninstall the Kotlin plugin from IntelliJ, switch back from Kotlin plugin preview to stable branch in IntelliJ and reinstall the Kotlin plugin (1.4.21), but still get the same error. Adding this:
tasks.withType<KotlinCompile> {
    kotlinOptions {
        println(version)
        useIR = true
    }
}
Does indeed print 1.4.21 on compilation, so I'm not quite sure what it still doesn't like.
OK - I'm still getting an error. I am using 1.4.21 now. Interestingly, commenting out all references to Kotlinx Serialization gives me a different error:
I now get the error:
java.lang.IllegalStateException: Backend Internal error: Exception during IR lowering
. Seems like a backend IR compiler error.
o

olonho

01/22/2021, 6:38 AM
Please try with
0.0.0-vsync-build29
as Compose version and
1.4.21-2
as Kotlin version