Moha.AZ
Moha.AZ

Reputation: 1852

This version 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

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!)."

Upvotes: 55

Views: 58586

Answers (9)

Sushant Gosavi
Sushant Gosavi

Reputation: 3825

For me actually By mistakenly I have added

buildFeatures {
    compose = true
}

Inside the multiplatform KMM project app level gradle file after removing this error is goan My kotlin and compose versions are

compose = "1.5.0"
kotlin = "1.9.0"

Upvotes: 0

code4rox
code4rox

Reputation: 1083

If you are using kotlin 2.0.0+ you need to add compose plugin

Project level gradle add this plugin

id("org.jetbrains.kotlin.plugin.compose") version "2.0.20"

build.gradle.kts (Project:__)

plugins {
    id("com.android.application") version "8.2.2" apply false
    id("org.jetbrains.kotlin.android") version "2.0.20" apply false
    id("org.jetbrains.kotlin.plugin.serialization") version "1.7.10" apply false
    id("org.jetbrains.kotlin.plugin.compose") version "2.0.20" // this version matches your Kotlin version

}

app level gradle add this plugin

id("org.jetbrains.kotlin.plugin.compose")

build.gradle.kts (Module:app)

plugins {
    id("com.android.application")
    id("org.jetbrains.kotlin.android")
    id("org.jetbrains.kotlin.plugin.serialization")
    id("org.jetbrains.kotlin.plugin.compose")
}

here also remove this

composeOptions {
        kotlinCompilerExtensionVersion = "1.3.2"
    }

Upvotes: 4

Siddharth Shakya
Siddharth Shakya

Reputation: 1613

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.

Latest Update : From Kotlin 2.0.0+ you don't have to worry about the compatibility.Use the Compose Compiler Gradle plugin to enable Compose.

Here is the full list of compatible versions:

Update : Updated latest versions

Compose Compiler Version Compatible Kotlin Version
1.5.12 1.9.23
1.5.8 1.9.22
1.5.7 1.9.21
1.5.6 1.9.21
1.5.5 1.9.20
1.5.4 1.9.20
1.5.3 1.9.10
1.5.2 1.9.0
1.5.1 1.9.0
1.5.0 1.9.0
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

Upvotes: 108

aleksandrbel
aleksandrbel

Reputation: 1490

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

Upvotes: 4

Dmitry Sergienko
Dmitry Sergienko

Reputation: 115

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
}

Upvotes: 4

kousen
kousen

Reputation: 3157

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.

Upvotes: 8

Martin Marconcini
Martin Marconcini

Reputation: 27226

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.

Upvotes: 10

KoalaZub
KoalaZub

Reputation: 1487

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.

Upvotes: 47

user9408023
user9408023

Reputation: 119

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.

Upvotes: 3

Related Questions