ilham fidatama
ilham fidatama

Reputation: 207

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

Upvotes: 10

Views: 7987

Answers (4)

Lakhwinder
Lakhwinder

Reputation: 1

Please add this task in your build.gradle.kts file:

tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
        kotlinOptions {
            jvmTarget = "1.8"
            freeCompilerArgs += ["-Xskip-prerelease-check"]
        }
    }

Upvotes: 0

Dmitry Kaltovich
Dmitry Kaltovich

Reputation: 2270

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.

Upvotes: 10

Imran Vora
Imran Vora

Reputation: 47

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

Upvotes: 4

Pedro Capela
Pedro Capela

Reputation: 69

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

Upvotes: 1

Related Questions