67

I've updated to Kotlin 1.5 last week, and after yesterday having seen the intention of Google to make Jetpack Compose the preferred option for designing UIs, I wanted to do some testing.

The issue is that having my project updated to Kotlin 1.5, when trying to build the project I get the following error:

This version (1.0.0-beta07) of the Compose Compiler requires Kotlin version 1.4.32 but you appear to be using Kotlin version 1.5.0 which is not known to be compatible.  Please fix your configuration (or `suppressKotlinVersionCompatibilityCheck` but don't say I didn't warn you!).

Is Kotlin 1.5 incompatible with Jetpack Compose? After googling the issue I found the 1.5.0-M2 release, which mentions Jetpack Compose, but not in an "incompatible" manner.

Do you have any answer to this? Should I use suppressKotlinVersionCompatibilityCheck? In that case, may I add it directly to android.kotlinOptions in the module's build.gradle file?

Thanks in advance.

Edit 1: I've found that I should add suppressKotlinVersionCompatibilityCheck as a builder arg:

android {
    ...
    kotlinOptions {
        ...
        freeCompilerArgs += [
            "-P",
"plugin:androidx.compose.compiler.plugins.kotlin:suppressKotlinVersionCompatibilityCheck=true"
        ]
        ...
    }
    ...
}

But it's still not compiling, I get this error from the compiler:

java.lang.NoClassDefFoundError: org/jetbrains/kotlin/ir/descriptors/WrappedSimpleFunctionDescriptor
    at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer.buildFunction(LiveLiteralTransformer.kt:842)
    at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer.irLiveLiteralGetter(LiveLiteralTransformer.kt:933)
    at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer.visitConst(LiveLiteralTransformer.kt:426)
    at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitConst(IrElementTransformerVoid.kt:138)
    at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitConst(IrElementTransformerVoid.kt:24)
    at org.jetbrains.kotlin.ir.expressions.impl.IrConstImpl.accept(IrConstImpl.kt:33)
    at org.jetbrains.kotlin.ir.expressions.IrExpression.transform(IrExpression.kt:33)
    at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer$visitCall$1$3.invoke(LiveLiteralTransformer.kt:624)
    at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer$visitCall$1$3.invoke(LiveLiteralTransformer.kt:158)
    at androidx.compose.compiler.plugins.kotlin.lower.DurableKeyVisitor.enter(DurableKeyVisitor.kt:96)
    at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer.enter(LiveLiteralTransformer.kt:191)
    at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer.access$enter(LiveLiteralTransformer.kt:158)
    at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer$visitCall$1.invoke(LiveLiteralTransformer.kt:623)
    at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer$visitCall$1.invoke(LiveLiteralTransformer.kt:158)
    at androidx.compose.compiler.plugins.kotlin.lower.DurableKeyVisitor.enter(DurableKeyVisitor.kt:96)
    at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer.enter(LiveLiteralTransformer.kt:191)
    at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer.visitCall(LiveLiteralTransformer.kt:612)
    at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitCall(IrElementTransformerVoid.kt:199)
    at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitCall(IrElementTransformerVoid.kt:24)
    at org.jetbrains.kotlin.ir.expressions.impl.IrCallImpl.accept(IrCallImpl.kt:47)
    at org.jetbrains.kotlin.ir.expressions.IrExpression.transform(IrExpression.kt:33)
    at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer$visitCall$1$3.invoke(LiveLiteralTransformer.kt:624)
    at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer$visitCall$1$3.invoke(LiveLiteralTransformer.kt:158)
    at androidx.compose.compiler.plugins.kotlin.lower.DurableKeyVisitor.enter(DurableKeyVisitor.kt:96)
    at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer.enter(LiveLiteralTransformer.kt:191)
    at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer.access$enter(LiveLiteralTransformer.kt:158)
    at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer$visitCall$1.invoke(LiveLiteralTransformer.kt:623)
    at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer$visitCall$1.invoke(LiveLiteralTransformer.kt:158)
    at androidx.compose.compiler.plugins.kotlin.lower.DurableKeyVisitor.enter(DurableKeyVisitor.kt:96)
    at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer.enter(LiveLiteralTransformer.kt:191)
    at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer.visitCall(LiveLiteralTransformer.kt:612)
    at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitCall(IrElementTransformerVoid.kt:199)
    at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitCall(IrElementTransformerVoid.kt:24)
    at org.jetbrains.kotlin.ir.expressions.impl.IrCallImpl.accept(IrCallImpl.kt:47)
    at org.jetbrains.kotlin.ir.expressions.IrExpression.transform(IrExpression.kt:33)
    at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer$visitBranch$1.invoke(LiveLiteralTransformer.kt:738)
    at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer$visitBranch$1.invoke(LiveLiteralTransformer.kt:158)
    at androidx.compose.compiler.plugins.kotlin.lower.DurableKeyVisitor.enter(DurableKeyVisitor.kt:96)
    at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer.enter(LiveLiteralTransformer.kt:191)
    at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer.visitBranch(LiveLiteralTransformer.kt:737)
    at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitBranch(IrElementTransformerVoid.kt:255)
    at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitBranch(IrElementTransformerVoid.kt:24)
    at org.jetbrains.kotlin.ir.expressions.impl.IrBranchImpl.transform(IrWhenImpl.kt:56)
    at org.jetbrains.kotlin.ir.expressions.IrWhen.transformChildren(IrWhen.kt:37)
    at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitExpression(IrElementTransformerVoid.kt:131)
    at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitWhen(IrElementTransformerVoid.kt:247)
    at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer.access$visitWhen$s1031542550(LiveLiteralTransformer.kt:158)
    at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer$visitWhen$1.invoke(LiveLiteralTransformer.kt:705)
    at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer$visitWhen$1.invoke(LiveLiteralTransformer.kt:158)
    at androidx.compose.compiler.plugins.kotlin.lower.DurableKeyVisitor.siblings(DurableKeyVisitor.kt:117)
    at androidx.compose.compiler.plugins.kotlin.lower.DurableKeyVisitor$siblings$1.invoke(DurableKeyVisitor.kt:131)
    at androidx.compose.compiler.plugins.kotlin.lower.DurableKeyVisitor.enter(DurableKeyVisitor.kt:96)
    at androidx.compose.compiler.plugins.kotlin.lower.DurableKeyVisitor.siblings(DurableKeyVisitor.kt:131)
    at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer.siblings(LiveLiteralTransformer.kt:192)
    at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer.visitWhen(LiveLiteralTransformer.kt:704)
    at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitWhen(IrElementTransformerVoid.kt:248)
    at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitWhen(IrElementTransformerVoid.kt:24)
    at org.jetbrains.kotlin.ir.expressions.IrWhen.accept(IrWhen.kt:29)
    at org.jetbrains.kotlin.ir.expressions.IrExpression.transform(IrExpression.kt:33)
    at org.jetbrains.kotlin.ir.expressions.IrExpression.transform(IrExpression.kt:26)
    at org.jetbrains.kotlin.ir.expressions.IrBlockBody.transformChildren(IrBody.kt:62)
    at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitBody(IrElementTransformerVoid.kt:108)
    at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitBlockBody(IrElementTransformerVoid.kt:117)
    at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer.access$visitBlockBody$s1031542550(LiveLiteralTransformer.kt:158)
    at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer$visitBlockBody$1.invoke(LiveLiteralTransformer.kt:795)
    at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer$visitBlockBody$1.invoke(LiveLiteralTransformer.kt:158)
    at androidx.compose.compiler.plugins.kotlin.lower.DurableKeyVisitor.siblings(DurableKeyVisitor.kt:117)
    at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer.siblings(LiveLiteralTransformer.kt:193)
    at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer.visitBlockBody(LiveLiteralTransformer.kt:794)
    at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitBlockBody(IrElementTransformerVoid.kt:118)
    at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitBlockBody(IrElementTransformerVoid.kt:24)
    at org.jetbrains.kotlin.ir.expressions.IrBlockBody.accept(IrBody.kt:54)
    at org.jetbrains.kotlin.ir.expressions.IrBody.transform(IrBody.kt:27)
    at org.jetbrains.kotlin.ir.declarations.IrFunction.transformChildren(IrFunction.kt:69)
    at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitDeclaration(IrElementTransformerVoid.kt:57)
    at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitFunction(IrElementTransformerVoid.kt:69)
    at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitSimpleFunction(IrElementTransformerVoid.kt:72)
    at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer.access$visitSimpleFunction$s1031542550(LiveLiteralTransformer.kt:158)
    at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer$visitSimpleFunction$1.invoke(LiveLiteralTransformer.kt:654)
    at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer$visitSimpleFunction$1.invoke(LiveLiteralTransformer.kt:158)
    at androidx.compose.compiler.plugins.kotlin.lower.DurableKeyVisitor.enter(DurableKeyVisitor.kt:96)
    at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer.enter(LiveLiteralTransformer.kt:191)
    at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer.visitSimpleFunction(LiveLiteralTransformer.kt:654)
    at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitSimpleFunction(IrElementTransformerVoid.kt:73)
    at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitSimpleFunction(IrElementTransformerVoid.kt:24)
    at org.jetbrains.kotlin.ir.declarations.IrSimpleFunction.accept(IrSimpleFunction.kt:29)
    at org.jetbrains.kotlin.ir.IrElement$DefaultImpls.transform(IrElement.kt:32)
    at org.jetbrains.kotlin.ir.IrElementBase.transform(IrElementBase.kt:19)
    at org.jetbrains.kotlin.ir.util.TransformKt.transformInPlace(transform.kt:35)
    at org.jetbrains.kotlin.ir.declarations.IrClass.transformChildren(IrClass.kt:67)
    at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitDeclaration(IrElementTransformerVoid.kt:57)
    at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitClass(IrElementTransformerVoid.kt:66)
    at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer.access$visitClass$s1031542550(LiveLiteralTransformer.kt:158)
    at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer$visitClass$1.invoke(LiveLiteralTransformer.kt:450)
    at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer$visitClass$1.invoke(LiveLiteralTransformer.kt:158)
    at androidx.compose.compiler.plugins.kotlin.lower.DurableKeyVisitor.siblings(DurableKeyVisitor.kt:117)
    at androidx.compose.compiler.plugins.kotlin.lower.DurableKeyVisitor$siblings$1.invoke(DurableKeyVisitor.kt:131)
    at androidx.compose.compiler.plugins.kotlin.lower.DurableKeyVisitor.enter(DurableKeyVisitor.kt:96)
    at androidx.compose.compiler.plugins.kotlin.lower.DurableKeyVisitor.siblings(DurableKeyVisitor.kt:131)
    at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer.siblings(LiveLiteralTransformer.kt:192)
    at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer.visitClass(LiveLiteralTransformer.kt:449)
    at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitClass(IrElementTransformerVoid.kt:67)
    at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitClass(IrElementTransformerVoid.kt:24)
    at org.jetbrains.kotlin.ir.declarations.IrClass.accept(IrClass.kt:56)
    at org.jetbrains.kotlin.ir.IrElement$DefaultImpls.transform(IrElement.kt:32)
    at org.jetbrains.kotlin.ir.IrElementBase.transform(IrElementBase.kt:19)
    at org.jetbrains.kotlin.ir.declarations.impl.IrFileImpl.transformChildren(IrFileImpl.kt:71)
    at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitPackageFragment(IrElementTransformerVoid.kt:41)
    at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitFile(IrElementTransformerVoid.kt:47)
    at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer.access$visitFile$s1031542550(LiveLiteralTransformer.kt:158)
    at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer$visitFile$1.invoke(LiveLiteralTransformer.kt:496)
    at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer$visitFile$1.invoke(LiveLiteralTransformer.kt:158)
    at androidx.compose.compiler.plugins.kotlin.lower.DurableKeyVisitor.siblings(DurableKeyVisitor.kt:117)
    at androidx.compose.compiler.plugins.kotlin.lower.DurableKeyVisitor.root(DurableKeyVisitor.kt:152)
    at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer.visitFile(LiveLiteralTransformer.kt:463)
    at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitFile(IrElementTransformerVoid.kt:48)
    at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitFile(IrElementTransformerVoid.kt:24)
    at org.jetbrains.kotlin.ir.declarations.impl.IrFileImpl.accept(IrFileImpl.kt:63)
    at org.jetbrains.kotlin.ir.declarations.IrFile.transform(IrFile.kt:48)
    at org.jetbrains.kotlin.ir.declarations.impl.IrModuleFragmentImpl.transformChildren(IrModuleFragmentImpl.kt:45)
    at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoidKt.transformChildrenVoid(IrElementTransformerVoid.kt:330)
    at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer.lower(LiveLiteralTransformer.kt:169)
    at androidx.compose.compiler.plugins.kotlin.ComposeIrGenerationExtension.generate(ComposeIrGenerationExtension.kt:80)
    at org.jetbrains.kotlin.backend.jvm.JvmIrCodegenFactory$convertToIr$1.invoke(JvmIrCodegenFactory.kt:120)
    at org.jetbrains.kotlin.backend.jvm.JvmIrCodegenFactory$convertToIr$1.invoke(JvmIrCodegenFactory.kt:116)
    at org.jetbrains.kotlin.psi2ir.Psi2IrTranslator.generateModuleFragment(Psi2IrTranslator.kt:91)
    at org.jetbrains.kotlin.backend.jvm.JvmIrCodegenFactory.convertToIr(JvmIrCodegenFactory.kt:140)
    at org.jetbrains.kotlin.backend.jvm.JvmIrCodegenFactory.convertToIr$default(JvmIrCodegenFactory.kt:66)
    at org.jetbrains.kotlin.backend.jvm.JvmIrCodegenFactory.generateModule(JvmIrCodegenFactory.kt:61)
    at org.jetbrains.kotlin.codegen.KotlinCodegenFacade.compileCorrectFiles(KotlinCodegenFacade.java:35)
    at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.generate(KotlinToJVMBytecodeCompiler.kt:592)
    at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli(KotlinToJVMBytecodeCompiler.kt:212)
    at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli$default(KotlinToJVMBytecodeCompiler.kt:155)
    at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:169)
    at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:52)
    at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:88)
    at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:44)
    at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:98)
    at org.jetbrains.kotlin.incremental.IncrementalJvmCompilerRunner.runCompiler(IncrementalJvmCompilerRunner.kt:386)
    at org.jetbrains.kotlin.incremental.IncrementalJvmCompilerRunner.runCompiler(IncrementalJvmCompilerRunner.kt:110)
    at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileIncrementally(IncrementalCompilerRunner.kt:303)
    at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileImpl$rebuild(IncrementalCompilerRunner.kt:99)
    at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileImpl(IncrementalCompilerRunner.kt:124)
    at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compile(IncrementalCompilerRunner.kt:74)
    at org.jetbrains.kotlin.daemon.CompileServiceImplBase.execIncrementalCompiler(CompileServiceImpl.kt:607)
    at org.jetbrains.kotlin.daemon.CompileServiceImplBase.access$execIncrementalCompiler(CompileServiceImpl.kt:96)
    at org.jetbrains.kotlin.daemon.CompileServiceImpl.compile(CompileServiceImpl.kt:1659)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at java.rmi/sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:359)
    at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:200)
    at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:197)
    at java.base/java.security.AccessController.doPrivileged(Native Method)
    at java.rmi/sun.rmi.transport.Transport.serviceCall(Transport.java:196)
    at java.rmi/sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:562)
    at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:796)
    at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:677)
    at java.base/java.security.AccessController.doPrivileged(Native Method)
    at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:676)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.lang.ClassNotFoundException: org.jetbrains.kotlin.ir.descriptors.WrappedSimpleFunctionDescriptor
    at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:471)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:589)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
    ... 164 more

Arnyminer Z
  • 5,784
  • 5
  • 18
  • 32

15 Answers15

70

Update:

Thanks @Samuel Luís for finding a Compose to Kotlin compatibility table https://developer.android.com/jetpack/androidx/releases/compose-kotlin


Update: androidx.compose.compiler:compiler:1.0.0-beta08 is released (June 2, 2021).

From this version, the expected version of Kotlin is 1.5.10.

dependencies {
    implementation "androidx.compose.compiler:compiler:1.0.0-beta08"
}

android {
    buildFeatures {
        compose true
    }

    composeOptions {
        kotlinCompilerVersion "1.5.10"
        kotlinCompilerExtensionVersion "1.0.0-beta08"
    }

    kotlinOptions {
        jvmTarget = "1.8"
    }
}

See more:


Compose compiler 1.0.0-beta07 is not supporting Kotlin 1.5.0 yet.

And I found that the changes of supporting Kotlin 1.5.0 have merged, but not released yet.

https://android-review.googlesource.com/c/platform/frameworks/support/+/1651538

For this moment, in my opinion, you should use 1.4.3 and wait for the next version (1.0.0:beta08 or 1.0.0)

atyc
  • 1,056
  • 7
  • 7
  • compose_version = '1.0.0-beta09' – Stigma Jun 23 '21 at 19:15
  • 5
    Note that `kotlinCompilerVersion` [can be safely removed](https://stackoverflow.com/questions/67005588/kotlincompilerversion-is-deprecated/67005686#67005686). Compose now uses the kotlin compiler defined in your `buildscript`. – Gabriele Mariotti Jul 09 '21 at 16:08
  • As mentioned in an answer below you can update the Kotlin version in your buildscript: `classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.10"` – David Jul 27 '21 at 08:23
  • 1
    Just use `kotlinCompilerExtensionVersion 1.0.0` – Fang Jul 29 '21 at 06:26
  • 2
    The use of `kotlinCompilerVersions` in `composeOptions` was deprecated, after which compose just used the kotlin version defined in the project level build file. Now, even that seems to be deprecated, since as of compose 1.0.1, there is no kotlin version specified in the buildScript. How to update it now? In fact, 'where' to? I am unable to build project. – Richard Onslow Roper Aug 07 '21 at 08:27
  • Do I need to revert my kotlin version from 1.5.21 to 1.5.10 inorder to use the latest stable version of Jetpack Compose?. Is there any other better solution? – Sonu Sanjeev Aug 08 '21 at 16:41
  • @MARSK, I changed it in `settings.gradle` file and it's working. – cgb_pandey Aug 09 '21 at 05:59
  • Yes that's the latest way of doing it. We must change the jetbrains dependency inside `settings.gradle` file. I even had a question regarding this, I'll copy the link and/or explanation as an answer. – Richard Onslow Roper Aug 09 '21 at 07:24
  • 1
    here's a table with the compiler's version per Kotlin's version https://developer.android.com/jetpack/androidx/releases/compose-kotlin – Samuel Luís Jun 30 '22 at 14:28
36

This is what I did with latest compose version as until I write today.

compose_version = '1.2.0-alpha01'

1) Delete following line if exists you do not need it: enter image description here

2) Update your Kotlin version with final version if needed how to do this -> click this link

3) Finally in build.gradle (:project) update compose version:

ext {
    compose_version = '1.2.0-alpha01'
}

And gradle plugin:

classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10"

Now you should not have any warnings with latest version.

F.Mysir
  • 2,838
  • 28
  • 39
  • 1
    If you don't want to use an alpha version of the library 1.1.1 is also compatible with kotlin 1.6.10. You can view the full Compose to Kotlin Compatibility Map here: https://developer.android.com/jetpack/androidx/releases/compose-kotlin – James Jordan Taylor Mar 31 '22 at 14:18
15
  • In the build.gradle file (project):

    Change classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.0"

    To classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.21"

  • In the build.gradle file (app):

    composeOptions {
                kotlinCompilerExtensionVersion compose_version
                kotlinCompilerVersion kotlin_version
            }
    

    compose_version will be 1.0.1

    kotlin_version will be 1.5.21

MohamedHarmoush
  • 1,033
  • 11
  • 17
  • 2
    "ComposeOptions.kotlinCompilerVersion is deprecated. Compose now uses the kotlin compiler defined in your buildscript." – shanwu Jan 08 '22 at 14:53
9

[update] compose_version = '1.0.0' is now stable for Kotlin 1.5.10

buildscript {
    ext {
        compose_version = '1.0.0'
    }
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.10"
    }
}
Lang Minh Nguyên
  • 3,648
  • 4
  • 10
  • 31
7

This version (1.0.0-beta07) of the Compose Compiler requires Kotlin version 1.4.32 but you appear to be using Kotlin version 1.5.0 which is not known to be compatible. Please fix your configuration (or suppressKotlinVersionCompatibilityCheck but don't say I didn't warn you!)

this version (1.0.0-beta08) of the Compose Compiler requires Kotlin version 1.5.10 but you appear to be using Kotlin version 1.4.31 which is not known to be compatible. Please fix your configuration (or suppressKotlinVersionCompatibilityCheck but don’t say I didn’t warn you!).

  • The version 1.0.0-beta07 requires Kotlin 1.4.32

  • The version 1.0.0-beta08 requires Kotlin 1.5.10

Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841
3

Check out this same question here Where to specify Kotlin Version for Compose as of Compose 1.0.1?

As of Compose 1.0.1, and Studio BumbleBee latest update (as of now), the required version of Kotlin required by compose is 1.5.10, however the Bumblebee update does not contain the kotlin version declaration even in the buildScript block. Now, you must change the declared dependency in the settings.gradle file, which is also where the studio picks it up from. Now, please note that even if you declared the correct version in the buildScript block in the project level build file, the project won't compile because studio will still fetch the version from the same place.

Also, if you are having a hard time finding out which version is required by the respective version of Compose, you can make the project, and when it fails, there's an option to run with scan to see full log output, which exposes the same. Alternatively, you could just edit it in the settings make it the default, whatever.

Richard Onslow Roper
  • 5,477
  • 2
  • 11
  • 42
2

My problem fixed by downgrading Kotlin from 1.5.20 to 1.5.10, and adding kotlinCompilerVersion "1.5.10" to composeOptions in build.gradle file. like this:

composeOptions {
    kotlinCompilerVersion "1.5.10"
    kotlinCompilerExtensionVersion '1.0.0-rc01'
}
Ehsan Shadi
  • 609
  • 6
  • 17
2

For me, I have missed adding the below lines.

composeOptions {
    kotlinCompilerExtensionVersion compose_version
}
Bharat Lalwani
  • 1,277
  • 15
  • 17
1

I had this problem when trying to migrate the old project to compose. For me, the solution was to create a compose activity. This can be done by hand or you can create an empty compose activity from the gallery.

TemZy
  • 23
  • 4
1

For me modifying the project level build.gradle file with the required version of kotlin (which is mentioned in the error message) fixed the issue.

Eg: My error message read:

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.21 which is not known to be compatible. Please fix your configuration

So I modified the kotlin version to 1.6.10 like below:

classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10"

And my problem got solved

Mr. Techie
  • 622
  • 7
  • 17
0

i get the error like this

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

and then I open the build.gradle(project) and change

classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.20'          

to this

classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.10' 

dont forget to sync and run the project. hope this work in you too!

Marcel Hofgesang
  • 951
  • 1
  • 15
  • 36
0

Faced this problem when adding a new module. The fix was adding the following to the new module:

buildFeatures {
  compose true
}

composeOptions {
  kotlinCompilerExtensionVersion compose_version
}

1.0.0-beta07 seems to be what it picks when no version is selected.

Muz
  • 5,866
  • 3
  • 47
  • 65
0

Faced this issue while updating Kotlin version from 1.6.10 to 1.6.20

And fixed it update compose_version from 1.1.1 to 1.2.0-alpha08

Enes Zor
  • 973
  • 8
  • 14
0

The works with Kotlin plugin 1.6.21:

composeOptions {
    kotlinCompilerExtensionVersion "1.2.0-rc01"
    kotlinCompilerVersion "1.6.21"
}
Martin Zeitler
  • 1
  • 19
  • 155
  • 216
-2

Make all of (upper of this page) https://stackoverflow.com/a/69508800/13432944

And mainly see this lines

composeOptions {
    kotlinCompilerExtensionVersion "1.0.4"
}

Android Studio Screenshot

Kirill I.
  • 11
  • 2
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Oct 26 '21 at 02:37