https://kotlinlang.org logo
#compose-desktop
Title
# compose-desktop
j

Javier

07/19/2022, 1:35 PM
Upgrading to
1.2.0-alpha01-dev748
is failing with
Copy code
This version (1.2.0) of the Compose Compiler requires Kotlin version 1.7.0 but you appear to be using Kotlin version 1.7.10 which is not known to be compatible.  Please fix your configuration (or `suppressKotlinVersionCompatibilityCheck` but don't say I didn't warn you!).
Meanwhile
1.2.0-alpha01-dev745
is working correctly 🤔
a

Arkadii Ivanov

07/19/2022, 1:37 PM
k

Kirill Grouchnikov

07/19/2022, 1:37 PM
Exactly what it says, there is no version officially compatible with 1.7.10
j

Javier

07/19/2022, 1:39 PM
ah, I was thinking that the old one was already compatible with 1.7.10
👍🏻 1
Is it planned to get a release with that support soon?
Looks like it is already merged, so I guess it will be released soon https://android-review.googlesource.com/c/platform/frameworks/support/+/2146844
j

jim

07/19/2022, 4:34 PM
FWIW, the compose compiler published by Google should work when building Compose for Desktop apps, and does support Kotlin 1.7.0
I know compose-mpp uses a different gradle plugin, I haven't investigated how to swap out the compiler, but seems likely there is some gradle incantation to do it, if anyone has any thoughts and wants to share.
j

Javier

07/19/2022, 4:41 PM
should be great to know how to do that, until know I am only using the Gradle plugin from JetBrains, hope google and jetbrains merge them into a “single” artifact in the future
a

Arkadii Ivanov

07/19/2022, 5:05 PM
It's possible to swap the compiler plugin, but the original question is about building against Kotlin 1.7.10, which is not possible with either plugin, isn't it?
j

jim

07/19/2022, 5:06 PM
The dev builds have supported 1.7.10 for a while
a

Arkadii Ivanov

07/19/2022, 5:08 PM
Alright then, the approach can be found here - https://github.com/JetBrains/compose-jb/issues/2108
However compilation may randomly fail because the non-android compose targets somehow depend on Kotlin version as well.
j

jim

07/19/2022, 5:12 PM
I'm not sure what you mean, can you elaborate? Compose-desktop and compose-android binaries should both be compatible with future versions of the kotlin stdlib, and the same compiler should work with both targets.
a

Arkadii Ivanov

07/19/2022, 5:13 PM
I mean, using different versions of the compiler plugin is possible with Android Jetpack Compose, there is even a Gardle API. But there is no official API for MPP Compose (AFAIK), and it looks like compose is still coupled with a certain compiler plugin and so with the Kotlin version.
j

jim

07/19/2022, 5:15 PM
When you say "MPP Compose", can we be specific here? Are we talking about compose-desktop or something else?
Did you try swapping out the compiler as suggested in https://github.com/JetBrains/compose-jb/issues/2108#issuecomment-1157978869 ?
Copy code
allprojects {
    configurations.all {
        resolutionStrategy.dependencySubstitution {
            substitute(module("org.jetbrains.compose.compiler:compiler")).apply {
                using(module("androidx.compose.compiler:compiler:1.2.1-dev-k1.7.10-27cf0868d10"))
            }
        }
    }
}
And adding the repository as per https://github.com/jimgoog/ComposeAppUsingPrereleaseComposeCompiler/blob/main/settings.gradle#L17
a

Arkadii Ivanov

07/19/2022, 5:18 PM
By MPP compose I mean the one published in https://maven.pkg.jetbrains.space/public/p/compose/dev
a

Arkadii Ivanov

07/19/2022, 5:19 PM
Yes I tried swapping a few weeks ago, there were various compilation errors described in that issue, especially with Compose for Web
Sorry, not compilation errors, but compiler crashes
j

jim

07/19/2022, 5:22 PM
Ok, yeah, the google binaries will work for compose-android and compose-desktop, those compiler binaries don't yet support web or ios, which is why I was repeatedly being explicit about compose-desktop despite being in the compose-desktop channel, and was asking for confirmation about what you mean when talking about MPP.
I think we're in agreement.
We're looking into what @Javier was mentioning, if it would be possible to ship a single artifact
👀 1
a

Arkadii Ivanov

07/19/2022, 5:25 PM
TBH, there was an NPE error during Gradle sync with Compose for Desktop, it was fixed later with a release officially compatible with Kotlin 1.7.0.
j

Javier

07/19/2022, 5:25 PM
that plus AGP integrated into KGP KMP plugin would be a nice 2022 for KMP
j

jim

07/19/2022, 5:28 PM
TBH, there was an NPE error during Gradle sync with Compose for Desktop, it was fixed later with a release officially compatible with Kotlin 1.7.0. (edited)
Compose Compiler versions are not expected to be compatible with any version of the Kotlin Compiler except that with which they were built/documented to support. The Kotlin-stdlib is stable, so Compose libraries compiled against the old kotlin-stdlib should work with newer kotlin-stdlibs.
that plus AGP integrated into KGP KMP plugin would be a nice 2022 for KMP
Yeah, something like that. We're looking at what it would take to unify the configurations too.
❤️ 2
a

Arkadii Ivanov

07/19/2022, 5:32 PM
Compose Compiler versions are not expected to be compatible with any version of the Kotlin Compiler except that with which they were built/documented to support. The Kotlin-stdlib is stable, so Compose libraries compiled against the old kotlin-stdlib should work with newer kotlin-stdlibs.
Of course. I was upgrading from Kotlin 1.6.10 to Kotlin 1.7.0, there was a dev build of the Jetpack Compose compiler for Kotlin 1.7.0. I bumped the Kotlin version to 1.7.0, and used the trick to substitute the Compose compiler for Kotlin 1.7.0, while keeping all Compose artifacts of version 1.1.1, and Gradle sync was failing with NPE.
My point is, as long as there is no official Gradle API to change the Compose compiler version for MPP Compose (e.g. android + desktop), you are doing it on your own risk 😁
There is also a comment in that issue:
I am using Compose with Kotlin 1.7.0 and it's working great. You need to use the latest build 1.2.0-alpha01-dev709. And for the compose compiler you need to use version 1.2.0-dev-k1.7.0-53370d83bb1 from here: https://androidx.dev/storage/compose-compiler/repository
I remember, I also had to bump the Compose version from the stable 1.1.1 to the latest 1.2.0-alpha to make everything working.
21 Views