I am currently working throug the example in the G...
# compose-desktop
d
I am currently working throug the example in the Getting Started README: https://github.com/JetBrains/compose-jb/blob/master/tutorials/Getting_Started/README.md and already got stuck. I get 'Class 'androidx.compose.ui.unit.IntSize' is compiled by a new Kotlin compiler backend and cannot be loaded by the old compiler' on several keywords. Any idea what I could be missing?
b
What kotlin version are you using?
Looks like you need 1.4.x
a
1.4.x and ir flag
d
Currently
Copy code
kotlin("jvm") version "1.4.10"
as this was what the IDEA wizard suggested to me, tho I also tried 1.4.0 as in the example.
b
There's an ir flag for jvm? :O
a
Either in Gradle properties or in kotlin-jvm language settings
d
Well, that is what IDEA generated for me from the 'new project Wizard'.
b
What's the gradle prop?
a
Don't remember right now, but compose won't work without it
d
gradle.properties:
Copy code
kotlin.code.style=official
settings.gradle.kts:
Copy code
rootProject.name = "JetpackSnow"

pluginManagement {
    repositories {
        gradlePluginPortal()
        maven("<https://maven.pkg.jetbrains.space/public/p/compose/dev>")
    }
}
Okay… so simply running
./gradlew tasks
with the example files, results in
Copy code
* What went wrong:
Execution failed for task ':tasks'.
> Could not create task ':run'.
   > 'org.gradle.api.provider.Property org.gradle.api.tasks.JavaExec.getMainClass()'
sigh
b
What's your jdk version?
Compose requires 11+
d
AdoptJDK 15
b
Odd. Could you try coretto jdk 11?
Although it should work with your jdk
d
Switching quickly to 11-coretto. 🙂
b
But most likely you need that jvm ir backend flag
d
Right now I have it exactly as in the Getting Started guide.
b
Yeah, reading the docs that looks incorrect
d
Reading the kotlin docs you linked, I added '
Copy code
kotlinOptions.useIR = true
to my build.gradle.kts. The document implies, that this is auto-enabled when using the plugin. Never the less, my IDEA also claims that kotlinOptions is an unresolved reference. I am struggling to grasp how those things play together in gradle.
o
b
You need to add this to kotlinOptions in the sourceSet or run task
d
Just wondering: Is this common knowledge and rather obvious that it needs to be added there and does not need to be mentioned on that documentation? And if so… how can I learn this? I have been using Gradle for a while now and some things are just really opaque to me. =/
b
Not a common knowledge for sure. Stuff like this is scattered all over the docs and release notes
Although I'd start here
d
Thank you, the help is very much appreciated. I will work through the docs and maybe some time later reach that point again where my example-compose-project is still failing… but might be able to ask smarter questions there. xD
b
Sure, haply to help and good luck!
a
Exact same thing happening to me using AdoptOpenJDK 11.0.8, Kotlin 1.4.10, JB-Compose build62. https://stackoverflow.com/questions/64717218/how-to-sync-build-gradle-kts-settings-with-intellij-linter
If you set the following config in the build.gradle.kts:
Copy code
tasks.withType<KotlinCompile> {
    kotlinOptions {
        jvmTarget = "1.8"
        useIR = true

        freeCompilerArgs += listOf("-Xuse-ir")
    }
}
Project builds and runs fine, but the intellij linter is somehow unable to detect them (from gradle) and shows red lines below. As a temporary fix you can pass
-Xuse-ir
in ProjectStructure -> Facets manually.