JetBrains / compose-multiplatform

Compose Multiplatform, a modern UI framework for Kotlin that makes building performant and beautiful user interfaces easy and enjoyable.
https://jetbrains.com/lp/compose-multiplatform
Apache License 2.0
15.8k stars 1.14k forks source link

UnsatisfiedLinkError: Can't load library: libskiko-macos-arm64.dylib #3831

Closed colletjbdev closed 8 months ago

colletjbdev commented 10 months ago

Describe the bug Unable to start the application compiled app. (It runs though using directly IntelliJ)

Affected platforms Select one of the platforms below:

Versions

To Reproduce Steps and/or the code snippet to reproduce the behavior:

  1. Write app's code
  2. Compile code using Gradle createDistribuable script (it is working)
  3. Run compiled app using Gradle runDistribuable OR double clicking the app's icon

Expected behavior A clear and concise description of what you expected to happen: The app should start.

Screenshots If applicable, add screenshots to help explain your problem: None available

Additional context Add any other context about the problem here: Here is the error log i got:

Exception in thread "main" java.lang.UnsatisfiedLinkError: Can't load library: /Users/XXX/Documents/Sources/Samples/ComposeDesktopDemo/build/compose/binaries/main/app/ComposeDesktopDemo.app/Contents/app/libskiko-macos-arm64.dylib at java.base/java.lang.ClassLoader.loadLibrary(Unknown Source) at java.base/java.lang.Runtime.load0(Unknown Source) at java.base/java.lang.System.load(Unknown Source) at org.jetbrains.skiko.Library.loadLibraryOrCopy(Library.kt:20) at org.jetbrains.skiko.Library.findAndLoad(Library.kt:85) at org.jetbrains.skiko.Library.load(Library.kt:59) at org.jetbrains.skia.impl.Library$Companion.staticLoad(Library.jvm.kt:12)

MatkovIvan commented 10 months ago

Cannot reproduce based on your description. Could you please try to reproduce it on our template?

colletjbdev commented 10 months ago

Cannot reproduce based on your description. Could you please try to reproduce it on our template?

Thanks for the feedback.

I cloned the repo, run Gradle Sync, then createDistribuable and then runDistribuable and end up with the same error.

MatkovIvan commented 10 months ago

Probably related to #3123

MatkovIvan commented 10 months ago

Just in case: you're using the arm64 version of JDK, right? Is build/compose/binaries/main/app/ComposeDesktopDemo.app/Contents/app/libskiko-macos-arm64.dylib file really missed in your file system?

colletjbdev commented 10 months ago

Just in case: you're using the arm64 version of JDK, right? Is build/compose/binaries/main/app/ComposeDesktopDemo.app/Contents/app/libskiko-macos-arm64.dylib file really missed in your file system?

Both files (libskiko-macos-arm64.dylib and libskiko-macos-arm64.dylib.sha256) are present in the folder mentionned.

What surprises me is I can run my app using the "Run" button on IntelliJ, but bundled in an application, i can't...

MatkovIvan commented 10 months ago

Just in case: you're using the arm64 version of JDK, right?

For now it looks like the issue is somewhere in the JDK installation. That's why I asked such a question

I can run my app using the "Run" button on IntelliJ, but bundled in an application, i can't

It is probably because of different JDK/JRE. Could you please try with different one?

dima-avdeev-jb commented 10 months ago

Can you please run following command: /usr/libexec/java_home --verbose

And reply with printed result

jamesoneill54 commented 9 months ago

Was there any resolution found here? I seem to be having the same issue. I've cloned the example repo with the following results:

Exception in thread "main" java.lang.UnsatisfiedLinkError: Can't load library: /.../compose-multiplatform-template/desktopApp/build/compose/binaries/main/app/KotlinMultiplatformComposeDesktopApplication.app/Contents/app/libskiko-macos-arm64.dylib
        at java.base/java.lang.ClassLoader.loadLibrary(Unknown Source)
        at java.base/java.lang.Runtime.load0(Unknown Source)
        at java.base/java.lang.System.load(Unknown Source)
        at org.jetbrains.skiko.Library.loadLibraryOrCopy(Library.kt:20)
        at org.jetbrains.skiko.Library.findAndLoad(Library.kt:85)
        at org.jetbrains.skiko.Library.load(Library.kt:59)
        at org.jetbrains.skia.impl.Library$Companion.staticLoad(Library.jvm.kt:12)
        at androidx.compose.ui.ConfigureSwingGlobalsForCompose_desktopKt.configureSwingGlobalsForCompose(ConfigureSwingGlobalsForCompose.desktop.kt:49)
        at androidx.compose.ui.ConfigureSwingGlobalsForCompose_desktopKt.configureSwingGlobalsForCompose$default(ConfigureSwingGlobalsForCompose.desktop.kt:38)
        at androidx.compose.ui.window.Application_desktopKt.application(Application.desktop.kt:110)
        at androidx.compose.ui.window.Application_desktopKt.application$default(Application.desktop.kt:105)
        at MainKt.main(main.kt:4)
        at MainKt.main(main.kt)
Failed to launch JVM

Any idea what I can do here to resolve?

dima-avdeev-jb commented 9 months ago

@jamesoneill54 Can you please also execute this command and copy result here: /usr/libexec/java_home --verbose

jamesoneill54 commented 9 months ago

Hi @dima-avdeev-jb, here's the output from me running that command:

Matching Java Virtual Machines (2):
    11.0.15 (x86_64) "Eclipse Adoptium" - "OpenJDK 11.0.15" 
    1.8.0_342 (arm64) "Azul Systems, Inc." - "Zulu 8.64.0.15" 

If it's of any help, I'm also using sdkman to manage java versions. The current version installed is:

❯ java --version
openjdk 17.0.4.1 2022-08-12 LTS
OpenJDK Runtime Environment Microsoft-40354 (build 17.0.4.1+1-LTS)
OpenJDK 64-Bit Server VM Microsoft-40354 (build 17.0.4.1+1-LTS, mixed mode)
dima-avdeev-jb commented 8 months ago

@jamesoneill54 Thanks! I supposed you are using x86_64 for launching Compose. Better to remove your x86_64 JDK and install ARM version. Or install ARM version and change path in JAVA_HOME environment variable.

jamesoneill54 commented 8 months ago

Hi again @dima-avdeev-jb, happy holidays!

I've removed the x86_64 JVM from my machine, so now the command above reads:

❯ /usr/libexec/java_home --verbose
Matching Java Virtual Machines (2):
    1.8.0_342 (arm64) "Azul Systems, Inc." - "Zulu 8.64.0.15" /Users/{user}/Library/Java/JavaVirtualMachines/azul-1.8.0_342/Contents/Home
    1.8.0_342 (arm64) "Azul Systems, Inc." - "Zulu 8.64.0.15" /Library/Java/JavaVirtualMachines/azul-1.8.0_342/Contents/Home
/Users/{user}/Library/Java/JavaVirtualMachines/azul-1.8.0_342/Contents/Home

My $JAVA_HOME is still set up using SDKMAN, and reads /Users/{user}/.sdkman/candidates/java/current.

Output of sdk current:

❯ sdk current

Using:

java: 17.0.4.1-ms
kotlin: 1.7.21

Unfortunately I'm seeing the same behaviour. After successfully running ./gradlew createDistributable, ./gradlew runDistributable does not work with the same JVM error as above.

Are there any further steps I can take?

dima-avdeev-jb commented 8 months ago

Are this JAVA_HOME JDK is X86_64 or ARM ? I think it is X86_64

jamesoneill54 commented 8 months ago

Listing the sdkman available java distributions, it's listing my currently installed version as ARM:

❯ sdk list java
================================================================================
Available Java Versions for macOS ARM 64bit
================================================================================
 Vendor        | Use | Version      | Dist    | Status     | Identifier
--------------------------------------------------------------------------------
 Corretto      |     | 21.0.1       | amzn    |            | 21.0.1-amzn
               |     | 17.0.9       | amzn    |            | 17.0.9-amzn
               |     | 11.0.21      | amzn    |            | 11.0.21-amzn
               |     | 8.0.392      | amzn    |            | 8.0.392-amzn
 Gluon         |     | 22.1.0.1.r17 | gln     |            | 22.1.0.1.r17-gln
               |     | 22.1.0.1.r11 | gln     |            | 22.1.0.1.r11-gln
 GraalVM CE    |     | 21.0.1       | graalce |            | 21.0.1-graalce
               |     | 17.0.9       | graalce |            | 17.0.9-graalce
 GraalVM Oracle|     | 21.0.1       | graal   |            | 21.0.1-graal
               |     | 17.0.9       | graal   |            | 17.0.9-graal
 Java.net      |     | 23.ea.3      | open    |            | 23.ea.3-open
               |     | 23.ea.2      | open    |            | 23.ea.2-open
               |     | 23.ea.1      | open    |            | 23.ea.1-open
               |     | 22.ea.29     | open    |            | 22.ea.29-open
               |     | 22.ea.28     | open    |            | 22.ea.28-open
               |     | 22.ea.27     | open    |            | 22.ea.27-open
               |     | 22.ea.26     | open    |            | 22.ea.26-open
               |     | 21.ea.35     | open    |            | 21.ea.35-open
 JetBrains     |     | 17.0.9       | jbr     |            | 17.0.9-jbr
               |     | 11.0.14.1    | jbr     |            | 11.0.14.1-jbr
 Liberica      |     | 21.0.1.fx    | librca  |            | 21.0.1.fx-librca
               |     | 21.0.1       | librca  |            | 21.0.1-librca
               |     | 17.0.9.fx    | librca  |            | 17.0.9.fx-librca
               |     | 17.0.9       | librca  |            | 17.0.9-librca
               |     | 11.0.21.fx   | librca  |            | 11.0.21.fx-librca
               |     | 11.0.21      | librca  |            | 11.0.21-librca
               |     | 8.0.392.fx   | librca  |            | 8.0.392.fx-librca
               |     | 8.0.392      | librca  |            | 8.0.392-librca
 Liberica NIK  |     | 23.1.1.r21   | nik     |            | 23.1.1.r21-nik
               |     | 22.3.4.r17   | nik     |            | 22.3.4.r17-nik
               |     | 22.3.4.r11   | nik     |            | 22.3.4.r11-nik
 Microsoft     |     | 21.0.1       | ms      |            | 21.0.1-ms
               |     | 17.0.9       | ms      |            | 17.0.9-ms
               | >>> | 17.0.4.1     | ms      | local only | 17.0.4.1-ms
               |     | 11.0.21      | ms      |            | 11.0.21-ms
 Oracle        |     | 21.0.1       | oracle  |            | 21.0.1-oracle
               |     | 17.0.9       | oracle  |            | 17.0.9-oracle
 SapMachine    |     | 21.0.1       | sapmchn |            | 21.0.1-sapmchn
               |     | 17.0.9       | sapmchn |            | 17.0.9-sapmchn
               |     | 11.0.21      | sapmchn |            | 11.0.21-sapmchn
 Semeru        |     | 17.0.9       | sem     |            | 17.0.9-sem
               |     | 11.0.21      | sem     |            | 11.0.21-sem
 Temurin       |     | 21.0.1       | tem     |            | 21.0.1-tem
               |     | 17.0.9       | tem     |            | 17.0.9-tem
               |     | 11.0.21      | tem     |            | 11.0.21-tem
 Tencent       |     | 17.0.9       | kona    |            | 17.0.9-kona
               |     | 11.0.21      | kona    |            | 11.0.21-kona
               |     | 8.0.392      | kona    |            | 8.0.392-kona
 Zulu          |     | 21.0.1       | zulu    |            | 21.0.1-zulu
               |     | 21.0.1.fx    | zulu    |            | 21.0.1.fx-zulu
               |     | 17.0.9       | zulu    |            | 17.0.9-zulu
               |     | 17.0.9.fx    | zulu    |            | 17.0.9.fx-zulu
               |     | 11.0.21      | zulu    |            | 11.0.21-zulu
               |     | 11.0.21.fx   | zulu    |            | 11.0.21.fx-zulu
               |     | 8.0.392      | zulu    |            | 8.0.392-zulu
               |     | 8.0.392.fx   | zulu    |            | 8.0.392.fx-zulu
 Unclassified  |     | 11.0.15      | none    | local only | 11.0.15
================================================================================
Omit Identifier to install default version 21.0.1-tem:
    $ sdk install java
Use TAB completion to discover available versions
    $ sdk install java [TAB]
Or install a specific version by Identifier:
    $ sdk install java 21.0.1-tem
Hit Q to exit this list view
================================================================================

This leads me to believe that it is using an ARM version correctly. Additionally, I've run ./gradlew runDistributable with info logs and the following line is printed about the JVM version used:

Received JVM installation metadata from '/Users/{user}/.sdkman/candidates/java/17.0.4.1-ms': {JAVA_HOME=/Users/{user}/.sdkman/candidates/java/17.0.4.1-ms, JAVA_VERSION=17.0.4.1, JAVA_VENDOR=Microsoft, RUNTIME_NAME=OpenJDK Runtime Environment, RUNTIME_VERSION=17.0.4.1+1-LTS, VM_NAME=OpenJDK 64-Bit Server VM, VM_VERSION=17.0.4.1+1-LTS, VM_VENDOR=Microsoft, OS_ARCH=aarch64}

Is there something I'm missing here? I'll try using a different distribution perhaps.

jamesoneill54 commented 8 months ago

@dima-avdeev-jb I've found the solution to my problem!

I changed my java distribution from my local versions 17.0.4.1-ms to the generic 17.0.4-ms, but this ran into the same issues. However, changing it then to 17.0.9-ms (or potentially another java version > 17.0.4) and it runs successfully.

Thank you for your help here, and let me know if there's any other info I can provide if you'd like to investigate this case any further.

okushnikov commented 1 month ago

Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.