Home > Software design >  This version (1.1.1) of the Compose Compiler requires Kotlin version 1.6.10 but you appear to be usi
This version (1.1.1) of the Compose Compiler requires Kotlin version 1.6.10 but you appear to be usi

Time:06-08

I'm using the latest Android Studio and I'm able to build and run my app fine with compose_version set to 1.0.5. However, I'd like to use the latest stable compose version 1.1.1.

I try to simply update the project build.gradle so it contains the following pointing to the desired compose version and the corresponding compatible kotlin version. These values are referenced in the app's build.gradle.

buildscript {
    ext {
        compose_version = '1.1.1'
        kotlin_version = '1.6.10'
    }

And in Android Studio, I go to Tools > Kotlin > Configure Kotlin Plugin Updates and download the latest Kotlin plugin (Early Access).

If I open Tools > Kotlin > Kotlin REPL, I see Welcome to Kotlin version 1.7.0-RC2-release-258 (JRE 11.0.12 0-b1504.28-7817840).

Now, I try to Rebuild Project.

I get the error: This version (1.1.1) of the Compose Compiler requires Kotlin version 1.6.10 but you appear to be using Kotlin version 1.5.31 which is not known to be compatible. Please fix your configuration (or suppressKotlinVersionCompatibilityCheck but don't say I didn't warn you!).

I don't wish to suppressKotlinVersionCompatibilityCheck given the warning, but I even tried that option and got other build errors.

Why is Kotlin version 1.5.31 being used? Shouldn't updating the Kotlin plugin have gotten Android Studio to switch to a more recent Kotlin version (as suggested by the Kotlin REPL message)? How can I make it such that Kotlin 1.6.10 is used and I stop getting the error?

CodePudding user response:

Using this help me.

build.gradle (:app)

composeOptions {
    kotlinCompilerExtensionVersion = "1.2.0-beta03"
}

CodePudding user response:

Compose uses the kotlin compiler defined in your buildscript block:

buildscript {
   ext.kotlin_version = '1.6.10'
   //....
   dependencies {
       classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
   }
}

If you are using the plugins block in settings.gradle or build.gradle:

pluginManagement {

    plugins {
        id 'org.jetbrains.kotlin.android' version '1.6.10' 
    }
}    
  • Related