Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kotlin compiler pre-release problem in android studio IDE

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

like image 373
ilham fidatama Avatar asked Apr 08 '20 12:04

ilham fidatama


People also ask

What is the latest version of Kotlin?

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.

How do I find my Kotlin plugin version?

You can check the Kotlin plugin version in Tools | Kotlin | Configure Kotlin Plugin Updates.

How do I change my Kotlin version?

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.


Video Answer


2 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.

like image 124
Dmitry Kaltovich Avatar answered Oct 12 '22 23:10

Dmitry Kaltovich


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

like image 37
Imran Vora Avatar answered Oct 13 '22 00:10

Imran Vora