I’m having problems with the project in Android Studio. I get a error message like this
Class ‘kotlin.Unit’ is compiled by a pre-release version of Kotlin and cannot be loaded by this version of the compiler
almost all of my program code in the project gets the same error message. even though it’s just a simple program code, like this
Kotlin 1.6 was released in November 2021. Kotlin 1.7 was released in June 2022, including the alpha version of the new Kotlin K2 compiler.
You can check the Kotlin plugin version in Tools | Kotlin | Configure Kotlin Plugin Updates.
Go to Intellij Preferences -> Build, Execution, Deployment -> Kotlin Compiler. Update Language version and Api version to the one you wish. This should be the accepted answer.
-Xskip-prerelease-check
to IDE.
My solution:
build.gradle.kts
plugins {
val kotlin = "1.5.0-M1"
kotlin("jvm") version kotlin
}
tasks{
withType<KotlinCompile> {
kotlinOptions {
freeCompilerArgs += listOf("-Xskip-prerelease-check")
}
}
}
File -> Invalidate caches / restart -> Invalidate and restart
would not help u.
I have same problem.
You are using pre-release version of kotlin. Use latest release version of kotlin to solve error.
Right now latest release version is 1.4.31. Update it on your project gradle file.
ext.kotlin_version = '1.4.31'
Happy to help :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With