https://kotlinlang.org logo
Title
r

Ryan Smith

04/10/2023, 11:25 PM
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

Dima Avdeev

04/11/2023, 5:51 AM
That Compose version are you trying?
r

Ryan Smith

04/11/2023, 3:09 PM
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

Dima Avdeev

04/15/2023, 3:55 PM
Can you please try to do the same with Compose 1.4.0 ?
r

Ryan Smith

04/15/2023, 4:30 PM
I'll give it a shot and let you know!
Unfortunately, same result. Here are some (hopefully) relevant bits from my build file.
d

Dima Avdeev

04/17/2023, 7:35 PM
Can you please create a minimal reproducible sample on GitHub ?
r

Ryan Smith

04/17/2023, 10:23 PM
This reproduced the error for me: https://github.com/AvlWx2014/critical-delay
Using the runReleaseDistributable Gradle task specifically
d

Dima Avdeev

04/18/2023, 7:15 AM
@alexey.tsvetkov Do you have Windows 10 or 11 to try this project?
a

alexey.tsvetkov

04/24/2023, 6:29 PM
@Ryan Smith can you try adding a proguard rule?
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

Ryan Smith

04/24/2023, 6:40 PM
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!