16

if you get this error in android studio "This version (1.3.2) of the Compose Compiler requires Kotlin version 1.7.20 but you appear to be using Kotlin version 1.8.0 which is not known to be compatible. Please fix your configuration (or suppressKotlinVersionCompatibilityCheck but don't say I didn't warn you!)."

Moha.AZ
  • 776
  • 2
  • 5
  • 11

7 Answers7

25

I came across the same issue just now. I resolved this issue by referencing the latest Compose compiler version from the Android Developer Jetpack page.

Here is the summary of the implementation(with a larger explanation via their page):

// :app build.gradle
android {
...

    composeOptions {
        kotlinCompilerExtensionVersion = "1.4.0"
    }

    kotlinOptions {
        jvmTarget = '1.8'
    }
}

After that I just synced and resolved any errors that showed up in my .kt files. Android Studio never picked up on the alpha variants of the compiler for me in build.gradle.

KoalaZub
  • 1,087
  • 8
  • 10
10

This issue can be fixed by using the exact same versions of Compose compiler & Kotlin. Suppose you are using Compose compiler version = 1.4.8 then you must have to use Kotlin version = 1.8.22 or vice-versa. If you use Kotlin version 1.8.21 then error is inevitable.

Here is the full list of compatible versions:

Compose Compiler Version Compatible Kotlin Version
1.4.8 1.8.22
1.4.7 1.8.21
1.4.6 1.8.20
1.4.5 1.8.20
1.4.4 1.8.10
1.4.3 1.8.10
1.4.2 1.8.10
1.4.1 1.8.0
1.4.0 1.8.0
1.4.0-alpha02 1.7.21
1.4.0-alpha01 1.7.20
1.3.2 1.7.20
1.3.1 1.7.10
1.3.0 1.7.10
1.3.0-rc02 1.7.10
1.3.0-rc01 1.7.10
1.3.0-beta01 1.7.10
1.2.0 1.7.0
1.2.0-rc02 1.6.21
1.2.0-rc01 1.6.21
1.2.0-beta03 1.6.21
1.2.0-beta02 1.6.21
1.2.0-beta01 1.6.21
1.2.0-alpha08 1.6.20
1.2.0-alpha07 1.6.10
1.2.0-alpha06 1.6.10
1.2.0-alpha05 1.6.10
1.2.0-alpha04 1.6.10
1.2.0-alpha03 1.6.10
1.2.0-alpha02 1.6.10
1.2.0-alpha01 1.6.10
1.1.1 1.6.10
1.1.0 1.6.10
1.1.0-rc03 1.6.10
1.1.0-rc02 1.6.10
1.1.0-rc01 1.6.0
1.1.0-beta04 1.6.0
1.1.0-beta03 1.5.31
1.1.0-beta02 1.5.31
1.1.0-beta01 1.5.31
1.1.0-alpha06 1.5.31
1.1.0-alpha05 1.5.31
1.0.5 1.5.31
1.0.4 1.5.31
1.1.0-alpha04 1.5.30
1.1.0-alpha03 1.5.30
1.0.3 1.5.30
1.1.0-alpha02 1.5.21
1.1.0-alpha01 1.5.21
1.0.2 1.5.21
1.0.1 1.5.21
1.0.0 1.5.10
1.0.0-rc02 1.5.10
1.0.0-rc01 1.5.10
Siddharth Shakya
  • 350
  • 4
  • 11
9

Update January 19th 2023

The Compose-Compiler version 1.4.0 has been released and it supports Kotlin 1.8.0.

Not all artifacts produced a release, so keep an eye on their release page for the others.

January 2023

The Latest version (1.4.0-alpha02) of Compose-UI works against Kotlin 1.7.21.

You have to force it, suppress the warnings, and potentially deal with any incompatibility, or wait for a new Compose release updated for Kotlin 1.8.x.

You can track the compatibility between Compose and Kotlin in the Compose to Kotlin Compatibility Map page.

Martin Marconcini
  • 26,875
  • 19
  • 106
  • 144
7

The previous answers are right, but here's the fix that worked for me. I allowed Android Studio to upgrade to Kotlin 1.8.20, which caused problems throughout. I then went to the top level build.gradle file and updated the Kotlin Android plugin:

plugins {
    id 'com.android.application' version '8.0.0' apply false
    id 'com.android.library' version '8.0.0' apply false
    id 'org.jetbrains.kotlin.android' version '1.8.20' apply false
}

That's what gave me the warning in this question, so I went to the build.gradle file in the app project and updated it:

composeOptions {
    kotlinCompilerExtensionVersion '1.4.5'
}

in the android section. Now it all is working again.

Eric Aya
  • 69,473
  • 35
  • 181
  • 253
kousen
  • 2,897
  • 3
  • 28
  • 26
2

In my case the issue fixed: build.gradle (module app)

composeOptions {
        kotlinCompilerExtensionVersion '1.4.7'
    }

build.gradle (Project)

plugins {
    id 'com.android.application' version '8.0.1' apply false
    id 'com.android.library' version '8.0.1' apply false
    id 'org.jetbrains.kotlin.android' version '1.8.21' apply false
}
2

Follow the official documentation to find the compatible versions : https://developer.android.com/jetpack/androidx/releases/compose-kotlin

aleksandrbel
  • 1,422
  • 3
  • 20
  • 38
1

I suppose so. I encountered the same problem. And here is another solution I learned from someone. Add this to module build.gradle in kotlinOptions {}. It is like this:

kotlinOptions {
        // other configurations
        freeCompilerArgs += [
                "-Xallow-jvm-ir-dependencies",
                "-P",
                "plugin:androidx.compose.compiler.plugins.kotlin:suppressKotlinVersionCompatibilityCheck=true"]
    }

It works for me, but might have potential bugs.