Describe the bug
Hey,
If you use Jetpack Compose with the android.composeOptions and the Google compiler extensions (see gradle.build.kts in app) and the kotlinx Serialization compiler plugin, the Gradle task debugCompileKotlin never ends. Maybe it even doesn't start...
To Reproduce
After disabling the compiler plugin, the gradle build finished
See https://github.com/hfhbd/ComposeTodo)
working commit: https://github.com/hfhbd/ComposeTodo/commit/12dfba4ce5080997f049d5fe7c1a27d926830c0b)
failing ci log: https://github.com/hfhbd/ComposeTodo/actions/runs/202626642
Expected behavior
A working build
Current Workaround
Write the serializer by yourself (https://github.com/hfhbd/ComposeTodo/commit/12dfba4ce5080997f049d5fe7c1a27d926830c0b) or move the DTOs into a separate module
Environment
We currently do not support Jetpack Compose, but it's on our radar for future releases
This issue only exists when using compose+serialization if used within the same module. Temporary workaround is to just separate the components into different modules (ui/app+network/serialization).
@jeremyrempel thank you!
It even works with useIR = true
@sandwwraith is the roadmap public?
@Brett-Best we are focused on finalizing 1.0 right now, so roadmap is not formed yet
@sandwwraith finalized! 馃帄
It would be awesome to know if fixing this issue is a matter of days, weeks or maybe months
I can't give any particular guarantees. However, we have a plan to align this with Compose Beta.
Kotlin team finally made it 馃帀 https://github.com/JetBrains/kotlin/releases/tag/v1.4.21-2
Many thanks to @sandwwraith 馃憤
Sounds great, but now when I try to compile with 1.4.21-2 I get the following error:
e: This version (1.0.0-alpha09) of the Compose Compiler requires Kotlin version 1.4.21 but you appear to be using Kotlin version 1.4.21-2 which is not known to be compatible. Please fix your configuration (or `suppressKotlinVersionCompatibilityCheck` but don't say I didn't warn you!).
I know that's not exactly a kotlin team issue anymore, but does anybody knows how we can actually use it? I could not find where to put that bloody suppressKotlinVersionCompatibilityCheck neither in the docs nor anywhere on the internet. That error message in not the clearest I've ever seen...
@acristescu
Kotlin 1.4.21-2 is currently not supported by Compose, but 1.4.21-2 is binary compatible with 1.4.21. So you have to set 1.4.21 in the compose options manually.
For example in project build.gradle.kts
plugins {
val kotlinVersion = "1.4.21-2"
kotlin("multiplatform") version kotlinVersion apply false
kotlin("plugin.serialization") version kotlinVersion apply false
id("com.android.application") version "7.0.0-alpha03" apply false
}
and in androidApp module build.gradle.kts
plugins {
id("com.android.application")
kotlin("android")
}
android {
buildFeatures {
compose = true
}
composeOptions {
kotlinCompilerVersion = "1.4.21"
kotlinCompilerExtensionVersion = composeVersion
}
...
}
Thank you for your answer, but I'm afraid I couldn't get it to work for an Android-only project. I changed the plugins block to the following:
plugins {
....
id 'kotlin-android' version "1.4.21-2"
id 'kotlin-kapt' version "1.4.21-2"
id 'kotlin-android-extensions' version "1.4.21-2"
....
}
and the composeOptions block to:
composeOptions {
kotlinCompilerExtensionVersion compose_version
kotlinCompilerVersion "1.4.21"
}
But Android Studio was having none of it:
Error resolving plugin [id: 'kotlin-android', version: '1.4.21-2']
> Plugin request for plugin already on the classpath must not include a version
Seems that I'm not allowed to specify a version for the plugins there. Is there a different approach that needs to be taken to make AndroidStudio happy?
^^ @jimgoog maybe you can help here with the correct option set for android project?
@acristescu Providing a sample project would help :) Do you do have a project build.gradle.kts containing
buildscript {
classpath("org.jetbrains:kotlin-gradle-dsl:1.4.20")
}
Then the Kotlin version is already set there and specifying elsewhere is forbidden.
Most helpful comment
This issue only exists when using compose+serialization if used within the same module. Temporary workaround is to just separate the components into different modules (ui/app+network/serialization).