https://kotlinlang.org logo
Docs
Join the conversationJoin Slack
Channels
100daysofcode
100daysofkotlin
100daysofkotlin-2021
advent-of-code
aem
ai
alexa
algeria
algolialibraries
amsterdam
android
android-architecture
android-databinding
android-studio
androidgithubprojects
androidthings
androidx
androidx-xprocessing
anime
anko
announcements
apollo-kotlin
appintro
arabic
argentina
arkenv
arksemdevteam
armenia
arrow
arrow-contributors
arrow-meta
ass
atlanta
atm17
atrium
austin
australia
austria
awesome-kotlin
ballast
bangladesh
barcelona
bayarea
bazel
beepiz-libraries
belgium
berlin
big-data
books
boston
brazil
brikk
budapest
build
build-tools
bulgaria
bydgoszcz
cambodia
canada
carrat
carrat-dev
carrat-feed
chicago
chile
china
chucker
cincinnati-user-group
cli
clikt
cloudfoundry
cn
cobalt
code-coverage
codeforces
codemash-precompiler
codereview
codingame
codingconventions
coimbatore
collaborations
colombia
colorado
communities
competitive-programming
competitivecoding
compiler
compose
compose-android
compose-desktop
compose-hiring
compose-ios
compose-mp
compose-ui-showcase
compose-wear
compose-web
connect-audit-events
corda
cork
coroutines
couchbase
coursera
croatia
cryptography
cscenter-course-2016
cucumber-bdd
cyprus
czech
dagger
data2viz
databinding
datascience
dckotlin
debugging
decompose
decouple
denmark
deprecated
detekt
detekt-hint
dev-core
dfw
docs-revamped
dokka
domain-driven-design
doodle
dsl
dublin
dutch
eap
eclipse
ecuador
edinburgh
education
effective-kotlin
effectivekotlin
emacs
embedded-kotlin
estatik
event21-community-content
events
exposed
failgood
fb-internal-demo
feed
firebase
flow
fluid-libraries
forkhandles
forum
fosdem
fp-in-kotlin
framework-elide
freenode
french
fritz2
fuchsia
functional
funktionale
gamedev
ge-kotlin
general-advice
georgia
geospatial
german-lang
getting-started
github-workflows-kt
glance
godot-kotlin
google-io
gradle
graphic
graphkool
graphql
graphql-kotlin
graviton-browser
greece
grpc
gsoc
gui
hackathons
hacktoberfest
hamburg
hamkrest
helios
helsinki
hexagon
hibernate
hikari-cp
hire-me
hiring
hongkong
hoplite
http4k
hungary
hyderabad
image-processing
india
indonesia
inkremental
intellij
intellij-plugins
intellij-tricks
internships
introduce-yourself
io
ios
iran
israel
istanbulcoders
italian
jackson-kotlin
jadx
japanese
jasync-sql
java-to-kotlin-refactoring
javadevelopers
javafx
javalin
javascript
jdbi
jhipster-kotlin
jobsworldwide
jpa
jshdq
juul-libraries
jvm-ir-backend-feedback
jxadapter
k2-early-adopters
kaal
kafka
kakao
kalasim
kapt
karachi
karg
karlsruhe
kash_shell
kaskade
kbuild
kdbc
kgen-doc-tools
kgraphql
kinta
klaxon
klock
kloudformation
kmdc
kmm-español
kmongo
knbt
knote
koalaql
koans
kobalt
kobweb
kodein
kodex
kohesive
koin
koin-dev
komapper
kondor-json
kong
kontent
kontributors
korau
korean
korge
korim
korio
korlibs
korte
kotest
kotest-contributors
kotless
kotlick
kotlin-asia
kotlin-beam
kotlin-by-example
kotlin-csv
kotlin-data-storage
kotlin-foundation
kotlin-fuel
kotlin-in-action
kotlin-inject
kotlin-latam
kotlin-logging
kotlin-multiplatform-contest
kotlin-mumbai
kotlin-native
kotlin-pakistan
kotlin-plugin
kotlin-pune
kotlin-roadmap
kotlin-samples
kotlin-sap
kotlin-serbia
kotlin-spark
kotlin-szeged
kotlin-website
kotlinacademy
kotlinbot
kotlinconf
kotlindl
kotlinforbeginners
kotlingforbeginners
kotlinlondon
kotlinmad
kotlinprogrammers
kotlinsu
kotlintest
kotlintest-devs
kotlintlv
kotlinultimatechallenge
kotlinx-datetime
kotlinx-files
kotlinx-html
kotrix
kotson
kovenant
kprompt
kraph
krawler
kroto-plus
ksp
ktcc
ktfmt
ktlint
ktor
ktp
kubed
kug-leads
kug-torino
kvision
kweb
lambdaworld_cadiz
lanark
language-evolution
language-proposals
latvia
leakcanary
leedskotlinusergroup
lets-have-fun
libgdx
libkgd
library-development
linkeddata
lithuania
london
losangeles
lottie
love
lychee
macedonia
machinelearningbawas
madrid
malaysia
mathematics
meetkotlin
memes
meta
metro-detroit
mexico
miami
micronaut
minnesota
minutest
mirror
mockk
moko
moldova
monsterpuzzle
montreal
moonbean
morocco
motionlayout
mpapt
mu
multiplatform
mumbai
munich
mvikotlin
mvrx
myndocs-oauth2-server
naming
navigation-architecture-component
nepal
new-mexico
new-zealand
newname
nigeria
nodejs
norway
npm-publish
nyc
oceania
ohio-kotlin-users
oldenburg
oolong
opensource
orbit-mvi
osgi
otpisani
package-search
pakistan
panamá
pattern-matching
pbandk
pdx
peru
philippines
phoenix
pinoy
pocketgitclient
polish
popkorn
portugal
practical-functional-programming
proguard
prozis-android-backup
pyhsikal
python
python-contributors
quasar
random
re
react
reaktive
realm
realworldkotlin
reductor
reduks
redux
redux-kotlin
refactoring-to-kotlin
reflect
refreshversions
reports
result
rethink
revolver
rhein-main
rocksdb
romania
room
rpi-pico
rsocket
russian
russian_feed
russian-kotlinasfirst
rx
rxjava
san-diego
science
scotland
scrcast
scrimage
script
scripting
seattle
serialization
server
sg-user-group
singapore
skia-wasm-interop-temp
skrape-it
slovak
snake
sofl-user-group
southafrica
spacemacs
spain
spanish
speaking
spek
spin
splitties
spotify-mobius
spring
spring-security
squarelibraries
stackoverflow
stacks
stayhungrystayfoolish
stdlib
stlouis
strife-discord-lib
strikt
students
stuttgart
sudan
swagger-gradle-codegen
swarm
sweden
swing
swiss-user-group
switzerland
talking-kotlin
tallinn
tampa
teamcity
tegal
tempe
tensorflow
terminal
test
testing
testtestest
texas
tgbotapi
thailand
tornadofx
touchlab-tools
training
tricity-kotlin-user-group
trójmiasto
truth
tunisia
turkey
turkiye
twitter-feed
uae
udacityindia
uk
ukrainian
uniflow
unkonf
uruguay
utah
uuid
vancouver
vankotlin
vertx
videos
vienna
vietnam
vim
vkug
vuejs
web-mpp
webassembly
webrtc
wimix_sentry
wwdc
zircon
Powered by Linen
compose-desktop
  • e

    Ewald

    06/03/2021, 2:59 PM
    Did anything change with relation to
    drawArc
    ? Sample in thread
    j
    i
    • 3
    • 12
  • y

    Yan Pujante

    06/03/2021, 4:57 PM
    The tutorial/documentation for the the Window API (M4) https://github.com/JetBrains/compose-jb/tree/master/tutorials/Window_API_new talks about handling close for example to ask "Close the document without saving?". If you select Menu/Quit or Command-Q (on macOS) it seems to bypass this mechanism entirely. Is there a way to respond to the "quit" event?
    j
    • 2
    • 4
  • t

    theapache64

    06/03/2021, 7:24 PM
    ✅ RESOLVED : I've upgrade my compose desktop version to
    0.4.0
    and kotlin version to
    1.5.10
    but am getting
    Caused by: java.lang.IllegalStateException: Unsupported metadata version. Check that your Kotlin version is >= 1.0
    (full stacktrace inside the thread) 🧵
    j
    • 2
    • 4
  • w

    wiktor

    06/03/2021, 9:25 PM
    ✅ RESOLVED : see the thread inside (TLDR; remove ~/.gradle catalog) hey 👋 I wonder if anybody has a problem with running desktop
    todo
    app from examples? Android and iOS works fine but for desktop I get (on mac):
    * What went wrong:
    Could not determine the dependencies of task ':desktop:compileJava'.
    > Could not resolve all dependencies for configuration ':desktop:compileClasspath'.
       > A problem occurred configuring project ':common:utils'.
          > org.gradle.api.internal.initialization.DefaultClassLoaderScope@2bfecddc must be locked before it can be used to compute a classpath!
    j
    e
    • 3
    • 8
  • x

    xxfast

    06/04/2021, 3:15 AM
    Is there a multiplatform template similar to this but with a
    iosMain
    and an ios target?
    j
    c
    • 3
    • 2
  • g

    Goregius

    06/04/2021, 2:39 PM
    I'm not sure if this is fixable but I've found that there's cursor lag when using an enabled G-Sync display with the DirectX renderer (in Windows) as I imagine that the cursor is tied to the fps in this case. Turning G-sync off (which isn't ideal as I have to do this globally) or using the OpenGL setting fixes this.
    i
    d
    a
    • 4
    • 9
  • c

    Colton Idle

    06/05/2021, 4:33 AM
    For my project that I'm converting from android compose to jetbrains compose, I created a theme that is basically a replica of the "jetsnack" compose sample app. https://github.com/android/compose-samples/tree/main/Jetsnack/app/src/main/java/com/example/jetsnack/ui/theme So my project (just like jetsnack) has a Color.kt, Shape.kt, Type.kt and Theme.kt. Moving those 4 files from android to Cfd works almost flawlessly except for two issues. 1. Type.kt -> creating a font is not working. Example:
    Font(R.font.montserrat_light, FontWeight.Light)
    How do you work with R.whatever in CfD? 2. Theme.kt -> Surprisingly most everything in here works too. But
    isSystemInDarkTheme
    does not compile on desktop.
    import androidx.compose.foundation.isSystemInDarkTheme
    Appreciate any advice. Thanks!
    k
    g
    • 3
    • 4
  • x

    xxfast

    06/05/2021, 9:04 AM
    What is the minimum
    jvmTarget
    for Compose for desktop?
    n
    a
    +2
    • 5
    • 10
  • t

    theapache64

    06/05/2021, 11:19 AM
    ✅ [RESOLVED]: the build runs, but am getting these IDE errors. Anyone got an idea on how to fix this? (Project SDK = OpenJDK 16) (IDE info inside the thread)
    e
    • 2
    • 6
  • a

    Aman Bansal

    06/05/2021, 3:22 PM
    What issue is this? I am trying compose for desktop
    java.lang.IncompatibleClassChangeError: Found class org.jetbrains.kotlin.ir.declarations.IrClass, but interface was expected
    	at androidx.compose.compiler.plugins.kotlin.VersionChecker.check(VersionChecker.kt:62)
    	at androidx.compose.compiler.plugins.kotlin.ComposeIrGenerationExtension.generate(ComposeIrGenerationExtension.kt:42)
    	at org.jetbrains.kotlin.backend.jvm.JvmIrCodegenFactory$generateModule$1.invoke(JvmIrCodegenFactory.kt:93)
    	at org.jetbrains.kotlin.backend.jvm.JvmIrCodegenFactory$generateModule$1.invoke(JvmIrCodegenFactory.kt:89)
    	at org.jetbrains.kotlin.psi2ir.Psi2IrTranslator.generateModuleFragment(Psi2IrTranslator.kt:91)
    	at org.jetbrains.kotlin.backend.jvm.JvmIrCodegenFactory.generateModule(JvmIrCodegenFactory.kt:106)
    	at org.jetbrains.kotlin.codegen.KotlinCodegenFacade.compileCorrectFiles(KotlinCodegenFacade.java:35)
    	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.generate(KotlinToJVMBytecodeCompiler.kt:595)
    	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli(KotlinToJVMBytecodeCompiler.kt:211)
    	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli$default(KotlinToJVMBytecodeCompiler.kt:154)
    	at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:169)
    	at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:52)
    	at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:88)
    	at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:44)
    	at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:98)
    	at org.jetbrains.kotlin.incremental.IncrementalJvmCompilerRunner.runCompiler(IncrementalJvmCompilerRunner.kt:386)
    	at org.jetbrains.kotlin.incremental.IncrementalJvmCompilerRunner.runCompiler(IncrementalJvmCompilerRunner.kt:110)
    	at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileIncrementally(IncrementalCompilerRunner.kt:286)
    	at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileImpl$rebuild(IncrementalCompilerRunner.kt:99)
    	at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileImpl(IncrementalCompilerRunner.kt:114)
    	at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compile(IncrementalCompilerRunner.kt:74)
    	at org.jetbrains.kotlin.daemon.CompileServiceImplBase.execIncrementalCompiler(CompileServiceImpl.kt:607)
    	at org.jetbrains.kotlin.daemon.CompileServiceImplBase.access$execIncrementalCompiler(CompileServiceImpl.kt:96)
    	at org.jetbrains.kotlin.daemon.CompileServiceImpl.compile(CompileServiceImpl.kt:1659)
    	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    	at java.rmi/sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:359)
    	at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:200)
    	at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:197)
    	at java.base/java.security.AccessController.doPrivileged(Native Method)
    	at java.rmi/sun.rmi.transport.Transport.serviceCall(Transport.java:196)
    	at java.rmi/sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:562)
    	at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:796)
    	at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:677)
    	at java.base/java.security.AccessController.doPrivileged(Native Method)
    	at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:676)
    	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    	at java.base/java.lang.Thread.run(Thread.java:834)
    :thread-please: 1
    j
    t
    k
    • 4
    • 16
  • c

    Colton Idle

    06/05/2021, 9:39 PM
    Multiplatform template comes with these two really handy run configurations. What part of a project dictates that? I want to add these configurations to my project since hitting the play button in the gutter next to a desktop project in AS doesn't work.
    i
    • 2
    • 2
  • x

    xxfast

    06/06/2021, 3:38 AM
    ✅ [RESOLVED]: Trying to share a
    @Composable
    button between
    desktop
    and
    android
    and getting this
    org.jetbrains.kotlin.backend.common.BackendException: Backend Internal error: Exception during code generation
    Complete stacktrace and source in the thread
    • 1
    • 3
  • s

    spierce7

    06/06/2021, 3:39 AM
    What’s the best way to create a Desktop Compose application with the equivalent of Android Flavors? I’d like to have 2 variants of my application - Internal and Production, and I’d like to exclude certain code from being in the production variant, and enable certain testing functionality in my internal variant, like server selection, etc. I tried using multiple jvm targets with the multiplatform plugin, and created a
    desktopMain
    source set, but I couldn’t use jvm dependencies in it (It was looked at / viewed as a common source-set I think). What else could I try?
    ➕ 1
    x
    • 2
    • 4
  • x

    xxfast

    06/07/2021, 2:53 AM
    Hi all - this might be a noobish question, but is there a way to run
    :packageDeb
    :packageMsi
    or any other native distribution tasks from a single OS (for eg:- mac osx)? If i were to automate builds through ci - would i need to spin up three pipelines for each build?
    🇳🇴 1
    o
    • 2
    • 1
  • s

    spierce7

    06/07/2021, 4:21 AM
    I’m using 0.4.0, and for some reason I don’t have access to the
    DropdownMenu
    widget. I see internal widgets like
    DropdownMenuContent
    and
    DropdownMenuPositionProvider
    , but not the actual
    DropdownMenu
    . Am I doing something wrong, or has this been removed from Desktop?
    v
    i
    +2
    • 5
    • 11
  • u

    uli

    06/07/2021, 10:16 AM
    I am seeing this old friend when building the Android target of a Compose MPP project
    > Task :androidApp:compileDebugKotlin
    warning: ATTENTION!
    This build uses unsafe internal compiler arguments:
    
    -XXLanguage:+NonParenthesizedAnnotationsOnFunctionalTypes
    
    This mode is not recommended for production use,
    as no stability/compatibility guarantees are given on
    compiler or generated code. Use it at your own risk!
    
    exception: java.lang.NoClassDefFoundError: kotlin/KotlinNothingValueException
    compose 0.0.0-unmerged-build79, kotlin 1.5.10, coroutines 1.4.32-native-mt, gradle 7.0.1 To my knowledge, all versions match. Any idea what could be going wrong?
    • 1
    • 1
  • k

    Kirill Grouchnikov

    06/07/2021, 11:05 AM
    Looks like querying OS light/dark mode is on the way to Compose Desktop via Skiko - https://github.com/JetBrains/skiko/pull/118
    🎉 3
    d
    c
    +3
    • 6
    • 18
  • s

    sigmadelta

    06/07/2021, 6:45 PM
    Hey everyone, for one of my applications I'd like to introduce a WebView as well. Is there a native component in Compose yet, or is it better to look into third party components for now?
    b
    b
    • 3
    • 2
  • r

    ron

    06/07/2021, 9:32 PM
    How to connect mutableStateFlow to Compose for desktop? I have a hot flow (from mqtt) that i would like to incorporate into Cards. As a self contained example:
    fun main() {
        val _state = MutableStateFlow("")
        val state = _state.asStateFlow()
        GlobalScope.launch {
            while (true) {
                _state.emit(Date().toString())
                delay(1000)
            }
        }
        GlobalScope.launch {
            state.collect {
                println("received $it")
            }
        }
        Window {
            var text by remember { mutableStateOf(state) }
            MaterialTheme {
                Text(text.value)
            }
        }
    
    }
    Whatever I try I either run into an exception that the state is out of sync. Or nothing works. I have searched the internet all over, but I have been unable to find anything that sheds any light on what I am trying to do.
    👀 2
    👍 1
    a
    • 2
    • 2
  • g

    gbaldeck

    06/08/2021, 5:54 PM
    how do the compose desktop builds work in terms of syncing with the core compose framework? For example, does build 0.5.0-build220 contain changes from the compose core done last friday? in this case it would be change made in the compose "framework" package
    i
    u
    • 3
    • 12
  • t

    Thiago

    06/09/2021, 1:22 AM
    As Compose Desktop use Skija and Skija has many bindings to native creating Pointers with managed class must I always use this resources with
    .use {}
    function to avoid leak pointers? I know there is many functions in the Compose canvas but the more powerful still using NativeCanvas.
    o
    • 2
    • 1
  • d

    darkmoon_uk

    06/09/2021, 6:46 AM
    It looks like the web components in
    0.5.0
    don't yet include a critical hotfix that was made to Web between their dev release
    14
    ->
    14.1
    . In Web
    14
    ,
    kotlinx.coroutines
    wasn't updated to
    1.5.0
    so JS build consistently fails with
    could not convert sym to ClassifierSymbol
    . I hope this can be fixed for
    0.5.0
    release, or it won't support 3-platform development 😢 @Igor Demin?
    o
    • 2
    • 2
  • k

    Kirill Grouchnikov

    06/09/2021, 12:51 PM
    Is
    application
    composable gone in 0.5.0 builds?
    i
    z
    • 3
    • 6
  • c

    Colton Idle

    06/09/2021, 2:43 PM
    I've only ever done android development in my life and I found this video on compose desktop useful. If anyone wants some material to read/listen to:

    https://www.youtube.com/watch?v=q8G6nzGhSEE▾

    :kotlin-intensifies: 11
    t
    • 2
    • 1
  • c

    Colton Idle

    06/09/2021, 7:53 PM
    This might be better in #multiplatform but I'll ask here first. If I want to write a KMP/KMM application and I want to share composables with desktop + android, and then I want a common networking module for desktop + android + ios, how would you recommend the module structure?
    /androidApp
    /commonCode
      /commonMain
      /desktopMain
      /iosMain
      /androidMain
    /iosApp
    /desktop
    or
    /androidApp
    /commonComposables
      /commonMain
      /desktopMain
      /androidMain
    /commonCode
      /commonMain
      /desktopMain
      /iosMain
      /androidMain
    /iosApp
    /desktop
    Basically would you just have a single common module and internally that somehow had both the shared networking code and shared composables (even no compose for ios ui) or just have two modules that are multiplatform modules. one for us and one for network?
    👍 1
    j
    x
    • 3
    • 3
  • r

    Rafs

    06/09/2021, 11:13 PM
    Is there a way to rotate a
    Path
    object in compose-desktop whilst pivoting at the center? The only transformation method that exists in the
    Path
    object is
    translate
    which internally converts the path object to a skija path and applies matrix transformation to it by calling
    Matrix33.makeTranslate
    . I tried to use the
    Matrix33.makeRotate
    method in this class but it only accepts an angle in degrees without a pivot.
    r
    • 2
    • 3
  • k

    Kirill Grouchnikov

    06/10/2021, 2:54 PM
    https://github.com/JetBrains/compose-jb/tree/master/tutorials/Keyboard has example of using
    Keyboard.setShortcut
    . This function is no longer found in build224
    o
    i
    • 3
    • 6
  • c

    Casey Brooks

    06/11/2021, 3:18 PM
    Has anyone been able to set up file associations when packaging a compose app (specifically on Mac .dmg)? I don’t see anything in the documentation, so I tried adding the jpackage flags manually to the
    AbstractJPackageTask
    in my
    build.gradle.kts.
    but it still doesn’t seem to be working
    n
    m
    • 3
    • 9
  • k

    Kirill Grouchnikov

    06/12/2021, 9:29 AM
    Latest additions in https://github.com/kirill-grouchnikov/aurora - popup enhancements. Combobox popups can be configured with max visible rows, at which point vertical scrolling kicks in. And the regular popups can now host scrollable panels. See the attached video that shows a vertically scrollable grid of buttons in a popup menu. Each button has action preview and action - action preview can be used for previewing the action result without making it permanent - see the rollover effect on changing the canvas gradient as the mouse is moved over that popup grid.
    aurora-popups.mov
    ❤️ 6
    :nice: 1
    • 1
    • 1
  • m

    Michael Paus

    06/12/2021, 10:43 AM
    I have a Compose app on macOS which works nicely from the IDE but when I package it as a DMG and then try to launch the app-image it dies without any message. If I try to open it from a terminal it tells me
    LSOpenURLsWithRole() failed with error -10810 for the file ...MyApp.app.
    which is also not very informative. When I then manually run the contents of the created app-image as a Java program I get:
    Caused by: org.jetbrains.skiko.LibraryLoadException: Cannot find libskiko-macos-x64.dylib.sha256, proper native dependency missing.
    	at org.jetbrains.skiko.Library.load(Library.kt:43)
    	at org.jetbrains.skija.impl.Library$Companion.staticLoad(Library.kt:12)
    	at org.jetbrains.skija.impl.Library.staticLoad(Library.kt)
    	at org.jetbrains.skija.Path.<clinit>(Path.java:27)
    The app-image contains both libskiko-macos-x64.dylib and libskiko-macos-x64.dylib.sha256. Does anybody have an idea what is going on here?
    d
    • 2
    • 16
Powered by Linen
Title
m

Michael Paus

06/12/2021, 10:43 AM
I have a Compose app on macOS which works nicely from the IDE but when I package it as a DMG and then try to launch the app-image it dies without any message. If I try to open it from a terminal it tells me
LSOpenURLsWithRole() failed with error -10810 for the file ...MyApp.app.
which is also not very informative. When I then manually run the contents of the created app-image as a Java program I get:
Caused by: org.jetbrains.skiko.LibraryLoadException: Cannot find libskiko-macos-x64.dylib.sha256, proper native dependency missing.
	at org.jetbrains.skiko.Library.load(Library.kt:43)
	at org.jetbrains.skija.impl.Library$Companion.staticLoad(Library.kt:12)
	at org.jetbrains.skija.impl.Library.staticLoad(Library.kt)
	at org.jetbrains.skija.Path.<clinit>(Path.java:27)
The app-image contains both libskiko-macos-x64.dylib and libskiko-macos-x64.dylib.sha256. Does anybody have an idea what is going on here?
d

darkmoon_uk

06/12/2021, 11:48 AM
Hi Michael. Yes, Java 16 uses the Java Modules system (aka Jigsaw) which sees the once huge and monolithic JDK broken up into many modules.
Unfortunately the packager is not automatically aware which of those is needed to be packaged, and you need to additionally specify them in Compose packagers Gradle configuration.
compose.desktop {
    application {
        ...
        nativeDistributions {
            ...
            modules("java.net.http")
☝️ I had the same error as you:
LSOpenURLsWithRole()
...that's because Java HTTP is missing and can be included with the above line.
modules("<http://java.net|java.net>.http")
❤️ 1
As for your second error; I've seen this before too, in my case it was because I'd mistakenly used the dependency
api(compose.desktop.common)
instead of
api(compose.desktop.currentOs)
...but it doesn't sound like this is the same in your case. You say you're running the contents of the App image manually; is this bypassing scripts that would otherwise be setting the JVM library path?
libskiko-macos-x64.dylib.sha256
would certainly need to be on the JVM's library path.
Re: the first issue; there's also a Gradle task called
suggestRuntimeModules
that can search the classes you're using and advise on the Java modules to include. I don't know how reliable it is.
m

Michael Paus

06/12/2021, 12:23 PM
You are my hero! It works now but the modules I had to add explicitly where:
modules("java.base","java.naming","java.prefs","java.scripting","java.sql","jdk.jfr","jdk.unsupported","jdk.unsupported.desktop","<http://jdk.crypto.ec|jdk.crypto.ec>","jdk.localedata")
I found them by using
jdeps
on my original JavaFX application where I do the packaging more manually and therefore have more insight on what is going on. Its embarrassing but I should have known that because I have written a tutorial about that for JavaFX myself together with Dirk Lemmermann. (https://github.com/dlemmermann/JPackageScriptFX)
👍 2
As for the second, obviously unrelated issue, I run the app as a Java app like this:
#!/bin/bash

APP_CONTENTS=build/compose/binaries/main/app/MapDemoDesktop.app/Contents

# This works only if the native commands are not stripped
#JAVA_HOME=${APP_CONTENTS}/runtime/Contents/Home

${JAVA_HOME}/bin/java \
-cp "${APP_CONTENTS}/app/*" \
-Djava.library.path="${APP_CONTENTS}/app/" \
-ea \
-Xmx2048m \
MainKt
d

darkmoon_uk

06/12/2021, 12:43 PM
Glad the modules issue is resolved 🙂 For 2nd; I assume then that
libskiko-macos-x64.dylib.sha256
can be found in
build/compose/binaries/main/app/MapDemoDesktop.app/Contents/app/
? Otherwise there's your problem.
m

Michael Paus

06/12/2021, 12:45 PM
The
suggestRuntimeModules
task also works. The list can then be shortened to
modules("java.instrument", "java.prefs", "java.sql", "jdk.unsupported","<http://jdk.crypto.ec|jdk.crypto.ec>","jdk.localedata")
The last two had to be added manually and where not suggested. The first of these is needed for https connections.
d

darkmoon_uk

06/12/2021, 12:46 PM
Thanks - Good to know about
java.instrument
for HTTPS! I'll run into that sooner or later...
m

Michael Paus

06/12/2021, 12:47 PM
No,
<http://jdk.crypto.ec|jdk.crypto.ec>
I meant the first of the two which I added manually.
👍 1
d

darkmoon_uk

06/12/2021, 12:48 PM
Is that right though?
<http://jdk.crypto.ec|jdk.crypto.ec>
...
...you got there before me 🙂
m

Michael Paus

06/12/2021, 12:51 PM
This is because the crypto stuff is loaded dynamically when you try to open the first https connection and jdeps cannot find that by a static analysis. I learned that the hard way 😉
👍 1
View count: 3