Kotlin compiler pre-release problem in android studio IDE

Viewed 4905

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

like this

3 Answers
You need to add argument-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") 
        }
    }
}
  • Intellij idea: image

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 :)

Check the updates from android studio and kotlin to and then try File -> Invalidate caches / restart -> Invalidate and restart

Related