Hi everyone, I'm running in to a weird error when ...
# compose-desktop
r
Hi everyone, I'm running in to a weird error when running a release distributable of my application on Windows. I can reproduce it by using the
runReleaseDistributable
Gradle task, but everything seems to work with non-release. I have a suspicion there's some missing piece of Proguard configuration I need in order to keep the right parts of
kotlinx-coroutines-swing
, but I'm not sure what it is. Has anyone run in to this before?
Alternatively, maybe some extra piece of JPackage configuration is missing to make sure it includes all the parts of
kotlinx-coroutines-swing
I need?
d
That Compose version are you trying?
r
1.3.1
Originally, 1.2.0 but I upgraded hoping that would help and still saw the same behavior
For reference I'm on Windows 11 also, but a colleague of mine who first reported this is on Windows 10 with the same behavior
d
Can you please try to do the same with Compose 1.4.0 ?
r
I'll give it a shot and let you know!
Unfortunately, same result. Here are some (hopefully) relevant bits from my build file.
d
Can you please create a minimal reproducible sample on GitHub ?
r
This reproduced the error for me: https://github.com/AvlWx2014/critical-delay
Using the runReleaseDistributable Gradle task specifically
d
@alexey.tsvetkov Do you have Windows 10 or 11 to try this project?
a
@Ryan Smith can you try adding a proguard rule?
Copy code
compose.desktop {
    application {
        mainClass = "MainKt"
        nativeDistributions {
            // ...

            buildTypes.release.proguard {
                configurationFiles.from("<http://desktop-rules.pro|desktop-rules.pro>")
            }
        }
    }
}

// <http://desktop-rules.pro|desktop-rules.pro>
-keep class kotlinx.coroutines.swing.SwingDispatcherFactory {}
At least on my machine the exception has disappeared after adding that.
r
I will try this this evening and let you know!
This seems to fix it! Im going to try going backwards to Compose 1.3.1 and Java 15 and make sure it still works, though I am confident it will. Thank you both for your help
Confirmed to work on Compose 1.3.1 and Java 15. Thanks again!
k
@Ryan Smith @alexey.tsvetkov where we can find progaurd for desktop compose
r
IIRC, at least for Compose 1.3.1 etc like I was using, proguard came with the project during setup. All I had to do was add a
<http://desktop-rules.pro|desktop-rules.pro>
file to my project and add
buildTypes.release.proguard {}
to my build file just like in Alexey's snippet above
k
@alexey.tsvetkov @Ryan Smith my error is this after building dmg either release or debug
r
That looks like you're missing a dependency, try adding `kotlinx-coroutines-swing`:
Copy code
dependencies {
                implementation(compose.desktop.currentOs)

                implementation(
                    "org.jetbrains.kotlinx:kotlinx-coroutines-core:${extra["kotlinx.coroutines.version"]}"
                )
                implementation(
                    "org.jetbrains.kotlinx:kotlinx-coroutines-swing:${extra["kotlinx.coroutines.version"]}"
                )
            }
k
Thanks my man
I'm a little bit confused about which dependency we need to keep under desktop gradle and which one under common gradle desktop section @Ryan Smith @alexey.tsvetkov can you clear it ?
r
I think you would keep coroutines-core under "common" and then add
-swing
,
-android
, etc in your platform-specific config
k
ALREADY SOLVED IT BRO, THANKS
r
Excellent 👍