I updated my KMP project to use koktlin 1.7.10 and...
# multiplatform
g
I updated my KMP project to use koktlin 1.7.10 and everything compiles and works fine. When I however use it as a dependency in another project I get a compiler error: "java.lang.NoSuchMethodError: 'void org.jetbrains.kotlin.cli.common.arguments.K2MetadataCompilerArguments.setUseK2(boolean)". The depending project uses the same kotlin version etc. Anyone encountered anything similar?
a
Can you elaborate a bit more? What Kotlin Gradle Plugin version do you use in other project?
g
I tried a few but right now it's: com.android.tools.buildG7.2.1
wrapper distribution 7.4-all
a
But that is Android Gradle Plugin. Can you then create a sample project? Where this can be reproduced?
g
hm that's a bit tricky because the update project is still in develop so can't publish it to public maven yet 😞
a
But I am asking for small sample, not your full project.
because I would like to reproduce it but I can't without information.
g
yes I understand, thank you
gimme a sec, i'll make a gist of the implementing project 🙂
👍 1
these are the build files from the implementing project: https://gist.github.com/buijs-dev/ee6b2ae4df8459c20b322bccf2bcc0aa
the platform module is build which throws the exception, there's only a simple HelloWorld class in the commonMain
I see now I send the wrong dep when you asked lol, sorry my bad. It's: "org.jetbrains.kotlinkotlin gradle plugin1.7.10"
a
So both projects have 1.7.10 🤔 it is weird
g
yep!
you can check the source project here if you want to have a look: https://github.com/buijs-dev/klutter/tree/develop
a
But this look like a bug or even regression. I will try to make a sample project based on your gist, but if you can do it as well that would be awesome. Because I'm confused with what is happening. This error:
"java.lang.NoSuchMethodError: 'void org.jetbrains.kotlin.cli.common.arguments.K2MetadataCompilerArguments.setUseK2(boolean)".
looks like Kotlin Gradle Plugin of version 1.7.10 tries to invoke Kotlin Compiler of version way older that 1.7. (like 1.5 or 1.6) And I don't see reasons why it does it.
g
yes
I also saw a weird log message about kotlin 1.4
I'll check if I can reproduce that
a
Do you have any buildSrc?
g
no I use lib-build as includeBuild
a
I'll check if I can reproduce that
Ok. yes, please
g
The 'org.jetbrains.kotlin.platform.*' plugins are deprecated and will no longer be available in Kotlin 1.4. Please migrate the project to the 'org.jetbrains.kotlin.multiplatform' plugin. See: https://kotlinlang.org/docs/reference/building-mpp-with-gradle.html
org.jetbrains.kotlin.platform is nowhere to be found in this project 😄
If I remove it and just apply the kotlin jvm plugin in the module build.gradle files then it builds without the weird log. I'll check if this also fixes the nosuchmethod exception (doubt it)
Copy code
kotlin("jvm") version "1.7.10"
nope nothing changed, same exception
okay scratch that, it works now
so to recap, the cause was applying this plugin in an included build "org.jetbrains.kotlin.gradle.plugin.KotlinPlatformJvmPlugin::class.java", which worked for the entire project itself, but when depending on the project it threw an exception