skip to Main Content

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?

10

Answers


  1. Using this help me.

    build.gradle (:app)

    composeOptions {
        kotlinCompilerExtensionVersion = "1.2.0-beta03"
    }
    
    Login or Signup to reply.
  2. 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' 
        }
    }    
    
    Login or Signup to reply.
  3. buildscript {
        dependencies {
            classpath 'com.android.tools.build:gradle:7.1.3'
        }
    }
    
    plugins {
        id 'org.jetbrains.kotlin.android' version '1.6.10' apply false
    }
    

    and build.gradle(Module)

    composeOptions {
        kotlinCompilerExtensionVersion '1.1.1'
    }
    
    Login or Signup to reply.
  4. Got the same error when using Compose 1.1.1. and Kotlin 1.7.0.

    Task :app:compileDebugKotlin FAILED
    e: This version (1.1.1) of the Compose Compiler requires
    Kotlin version 1.6.10 but you appear to be using Kotlin version 1.7.0
    which is not known to be compatible. Please fix your configuration (or suppressKotlinVersionCompatibilityCheck but don’t say I didn’t warn you!).

    Changed the below block in my build.gradle (app module)

    composeOptions {
        kotlinCompilerExtensionVersion 1.2.0
    }
    

    This is my plugins block in build.gradle (project):

    plugins {
        id 'com.android.application' version '7.2.1' apply false
        id 'com.android.library' version '7.2.1' apply false
        id 'org.jetbrains.kotlin.android' version '1.6.21' apply false
        id 'org.jetbrains.kotlin.jvm' version '1.7.0' apply false
    }
    

    This Android developers page helped with picking the compatible versions :-

    Compose to Kotlin Compatibility Map

    Don’t forget to sync and rebuild.

    Login or Signup to reply.
  5. There are 3 things you need to ensure are in sync(compatible with the other) for kotlin to work properly.

    1)compose_ui_version=’1.2.1′ of buildscript in build.gradle(project)

    2)plugin ‘org.jetbrains.kotlin.android’ version ‘1.7.10’ in build.gradle(project)

    3)kotlinCompilerExtensionVersion ‘1.3.1’ in composeOptions in build.gradle(app)

    To get the latest version of compose compiler and its corresponding kotlin version check here.

    Login or Signup to reply.
  6. for me what I had to edit is to locate build graddle(Project):

    1. first load compose_version to see the latest stable compose_version.
    
    
        buildscript {
        ext {
            //2. change here to the latest stable (compose_version) that you got in step 1
            compose_version = '1.3.0'
        }
        repositories {
            google()
            mavenCentral()
        }
        dependencies {
           //when you run you app, The next error will tell you the version of Kotlin that the latest compose_version needs, edit as below to the version required in the error
            classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.10'
        
        
        }
    
    Login or Signup to reply.
    1. Go to your project level build.gradle file
    2. There in the plugin section below mentioned 2 libraries has to be in the same version to remove this error:

    {

    ...
    
    id 'org.jetbrains.kotlin.android' version '1.6.10' apply false
    
    id 'org.jetbrains.kotlin.jvm' version '1.6.10' apply false
    

    }

    1. If required, change:

    compileSdk 33

    &

    targetSdk to 33

    . (inside app level build.gradle file).

    1. Now sync the project & reload the priview. It will work fine.
    Login or Signup to reply.
  7. you need to set this in your build.gradle

    composeOptions {
       kotlinCompilerExtensionVersion compose_version
       kotlinCompilerVersion kotlin_version
    }
    
    Login or Signup to reply.
  8. you should update your compose compiler
    from build.gardle.app make it "kotlinCompilerExtensionVersion" last version of compose compiler

    composeOptions {
        kotlinCompilerExtensionVersion 'last version'
    }
    

    you can see lastest update from https://developer.android.com/jetpack/androidx/releases/compose-compiler

    and make sure you use last version of kotlin also

    Login or Signup to reply.
  9. To solve this problem I updated my dependencies versions.

    in build.gradle (Project):

    buildscript {
        ext {
            compose_ui_version = '1.4.0'
        }
    }
    
    plugins {
        ...
        id 'org.jetbrains.kotlin.android' version '1.8.0' apply false
    }
    

    in bui.gradle ( :app):

    composeOptions {
        kotlinCompilerExtensionVersion '1.4.0'
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search