vinceglb / FileKit

Pick and save Files, Medias and Folder for Kotlin Multiplatform / KMP and Compose Multiplatform / CMP
https://vinceglb.github.io/FileKit/
MIT License
238 stars 8 forks source link

Unable to locate JNA native support library #48

Open egorikftp opened 1 week ago

egorikftp commented 1 week ago

Hello, i'm trying to migrate from https://github.com/Wavesonics/compose-multiplatform-file-picker to new library and faced crash.

Exception in thread "AWT-EventQueue-0 @coroutine#9527" java.lang.UnsatisfiedLinkError: Unable to locate JNA native support library
    at com.sun.jna.Native.loadNativeDispatchLibrary(Native.java:1014)
    at com.sun.jna.Native.<clinit>(Native.java:221)
    at io.github.vinceglb.filekit.core.platform.mac.foundation.Foundation.<clinit>(Foundation.kt:25)
    at io.github.vinceglb.filekit.core.platform.mac.foundation.Foundation$NSAutoreleasePool.<init>(Foundation.kt:563)
    at io.github.vinceglb.filekit.core.platform.mac.MacOSFilePicker.callNativeMacOSPicker(MacOSFilePicker.kt:57)
    at io.github.vinceglb.filekit.core.platform.mac.MacOSFilePicker.pickFile(MacOSFilePicker.kt:16)
    at io.github.vinceglb.filekit.core.FileKit$pickFile$2.invokeSuspend(FileKit.jvm.kt:28)

The library uses inside intellig idea plugin to choose file from system.

https://github.com/ComposeGears/Valkyrie/blob/95388a9fc803854274284de260be7df496df4783/plugin/src/main/kotlin/io/github/composegears/valkyrie/ui/screen/conversion/ConversionScreen.kt#L89

Migrated version:

 val filePicker = rememberFilePickerLauncher(
        type = PickerType.File(listOf("svg", "xml")),
        mode = PickerMode.Single,
        initialDirectory = settings.initialDirectory,
        onResult = { file ->
            file?.let {
                onSelectFile(it.file)
            }
        }
    )

Library version: 0.6.1 Machine: Mackbook Pro M3

vinceglb commented 1 week ago

Hey, thanks for reporting this!

I found this issue reported to Jetbrains with this comment: https://youtrack.jetbrains.com/issue/SCL-22499/scala-Error-Unable-to-locate-JNA-native-support-library#focus=Change-27-9799281.0-0.pinned

Can you check if your JDK version is an arm64 one and not x64 like describe?

Also, if your setup looks good, can you create a minimal project reproducing the crash? 🙏

egorikftp commented 1 week ago

Looks like jdk correct. Tested on your repository sample and it works as expected.

You can try to reproduce from this branch: https://github.com/ComposeGears/Valkyrie/tree/bug/filekit

To run you need Intellij IDEA (i use latest 2024.1.4) with installed DevKit plugin Run using gradle command ./gradlew runIde and see plugin

Screenshot 2024-06-28 at 15 13 43