Home > front end >  Create jar from desktop jetpack compose project
Create jar from desktop jetpack compose project

Time:01-07

Can't create Jar file for Kotlin desktop project using Jetpack Compose.
I have 2 launchers: one with JavaFx and socond with Compose. The one with JavaFx is working fine. But When I try to execute Compose version of Jar - I'm getting error:

P:\IntelijIDEAProjects\cliker\clicker\app\build\libs>java -jar app-1.1-COMPOSE.jar
Exception in thread "main" java.lang.ExceptionInInitializerError
        at androidx.compose.ui.awt.ComposeLayer.<init>(ComposeLayer.desktop.kt:92)
        at androidx.compose.ui.awt.ComposeWindowDelegate.<init>(ComposeWindowDelegate.desktop.kt:54)
        at androidx.compose.ui.awt.ComposeWindow.<init>(ComposeWindow.desktop.kt:61)
        at androidx.compose.ui.awt.ComposeWindow.<init>(ComposeWindow.desktop.kt:59)
        at androidx.compose.ui.window.Window_desktopKt$Window$3.invoke(Window.desktop.kt:162)
        at androidx.compose.ui.window.Window_desktopKt$Window$3.invoke(Window.desktop.kt:156)
        at androidx.compose.ui.window.Window_desktopKt$Window$10$1.invoke(Window.desktop.kt:378)
        at androidx.compose.ui.window.Window_desktopKt$Window$10$1.invoke(Window.desktop.kt:377)
        at androidx.compose.ui.window.AwtWindow_desktopKt$AwtWindow$2.invoke(AwtWindow.desktop.kt:75)
        at androidx.compose.ui.window.AwtWindow_desktopKt$AwtWindow$2.invoke(AwtWindow.desktop.kt:74)
        at androidx.compose.runtime.DisposableEffectImpl.onRemembered(Effects.kt:81)
        at androidx.compose.runtime.CompositionImpl$RememberEventDispatcher.dispatchRememberObservers(Composition.kt:1032)
        at androidx.compose.runtime.CompositionImpl.applyChangesInLocked(Composition.kt:793)
        at androidx.compose.runtime.CompositionImpl.applyChanges(Composition.kt:813)
        at androidx.compose.runtime.Recomposer.composeInitial$runtime(Recomposer.kt:827)
        at androidx.compose.runtime.CompositionImpl.setContent(Composition.kt:519)
        at androidx.compose.ui.window.Application_desktopKt$awaitApplication$2$1$2.invokeSuspend(Application.desktop.kt:219)
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
        at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
        at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:313)
        at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:770)
        at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721)
        at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:715)
        at java.base/java.security.AccessController.doPrivileged(Native Method)
        at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
        at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:740)
        at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
        at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
        at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
        at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
        at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
        at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
Caused by: org.jetbrains.skiko.LibraryLoadException: Cannot find skiko-windows-x64.dll.sha256, proper native dependency missing.
        at org.jetbrains.skiko.Library.findAndLoad(Library.kt:105)
        at org.jetbrains.skiko.Library.load(Library.kt:59)
        at org.jetbrains.skiko.SkiaLayer.<clinit>(SkiaLayer.awt.kt:28)
        ... 32 more

Running project from Main class is working fine. My goal is to build .exe file of this project. Perhaps there is any other ways?
The project available on github: https://github.com/HermanAleksey/BloodWebPumper

CodePudding user response:

You got this error message because you have not bundled the native Skiko dll. I would not recommend building a jar or an exe. Just follow this tutorial from Jetbrains https://github.com/JetBrains/compose-jb/tree/master/tutorials/Native_distributions_and_local_execution to build a native installer for your platform.

  • Related