Network calls not working in EXE distribution build of Compose for Desktop Application

609 Views Asked by At

I have used Ktor JVM Client for doing network calls in Compose for Desktop Application.

Network calls are working fine in Debug build means when I am just running the application it's working fine.

But when I create the EXE distribution file, by executing the packageExe task in Gradle, it's creating an EXE file. I have installed it on my machine. Then I am running the application and I am seeing that network calls are not working. I have checked internet is working properly.

Please provide a solution to fix this issue. Thanks in advance.

1

There are 1 best solutions below

0
On BEST ANSWER

Your question doesn't leave any details about the failure type (compile error? runtime exception? Empty data? etc.).

But if I had to speculate based on such limited information, I'd guess it's probably this: https://github.com/JetBrains/compose-jb/issues/429

Specifically, when packaging, you need to specify which JVM modules you want to be packed into your distributable app, and likely you are missing your crypto module. Try something like this:

compose.desktop {
    application {
        mainClass = "MainKt"
        nativeDistributions {
            modules("jdk.crypto.ec")

            targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb)
            packageName = "untitled"
        }
    }
}