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
Using this help me.
build.gradle (:app)
Compose uses the kotlin compiler defined in your
buildscript
block:If you are using the
plugins
block insettings.gradle
orbuild.gradle
:and build.gradle(Module)
Got the same error when using Compose
1.1.1.
and Kotlin1.7.0
.Changed the below block in my build.gradle (app module)
This is my plugins block in build.gradle (project):
This Android developers page helped with picking the compatible versions :-
Compose to Kotlin Compatibility Map
Don’t forget to sync and rebuild.
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.
for me what I had to edit is to locate build graddle(Project):
&
. (inside app level build.gradle file).
you need to set this in your build.gradle
you should update your compose compiler
from
build.gardle.app
make it "kotlinCompilerExtensionVersion" last version of compose compileryou can see lastest update from https://developer.android.com/jetpack/androidx/releases/compose-compiler
and make sure you use last version of kotlin also
To solve this problem I updated my dependencies versions.
in
build.gradle (Project)
:in
bui.gradle ( :app)
: