Skip to content

Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin #457

@raxod502

Description

@raxod502

I have a working Android project (that is, ./gradlew build builds an apk file that can be installed and run) which is written in Kotlin. When I open the project in Emacs with LSP using kotlin-language-server, I receive the following diagnostic on every line of code:

Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.8.0, expected version is 1.6.0. The class is loaded from /home/raxod502/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.8.20/e72fc5e03ec6c064c678a6bd0d955c88d55b0c4a/kotlin-stdlib-1.8.20.jar!/kotlin/Unit.class 

I checked Editor integration and Troubleshooting but did not see any relevant tips. I also searched the issue tracker but found only #198 (comment) as a reference, which doesn't seem relevant in this case.

Here's my build.gradle.kts:

plugins { id("com.android.application") version "7.4.2" id("org.jetbrains.kotlin.android") version "1.8.20" } repositories { google() mavenCentral() } android { compileSdkVersion(32) namespace = "redacted" defaultConfig { applicationId = "redacted" minSdkVersion(16) targetSdkVersion(32) versionCode = 1 versionName = "0.1.0" } buildTypes { getByName("release") { isMinifyEnabled = false } } compileOptions { sourceCompatibility = JavaVersion.VERSION_17 targetCompatibility = JavaVersion.VERSION_17 } } dependencies { implementation("androidx.appcompat:appcompat:1.2.0") implementation("com.google.android.material:material:1.2.0") implementation("androidx.constraintlayout:constraintlayout:2.0.4") } 

I don't, to my knowledge, have Kotlin installed globally on my system. The only place it's installed is via Gradle in this project, where the version is specified in build.gradle.kts as 1.8.20. I am not sure where this other 1.6.0 version number is coming from that is being referenced by kotlin-language-server.

If it would help in diagnosing the issue, I am happy to provide a sample project that reproduces the issue, or relevant logs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions