10

I try to compile https://github.com/CuriousNikhil/k5-compose in IntelliJ (Apple-Silicon) on an M1 MacbookPro, I got the below error

Caused by: org.jetbrains.skiko.LibraryLoadException: Cannot find libskiko-macos-arm64.dylib.sha256, proper native dependency missing.
    at org.jetbrains.skiko.Library.load(Library.kt:71)
    at org.jetbrains.skiko.HardwareLayer.<clinit>(HardwareLayer.kt:10)

How can I solve this issue?

Elye
  • 53,639
  • 54
  • 212
  • 474

5 Answers5

12

In the build.gradle.kts of the project, change implementation(compose.desktop.currentOs) to implementation(compose.desktop.macos_arm64)

Konstantin Annikov
  • 11,655
  • 4
  • 27
  • 40
  • 1
    Thanks - I was building a jar on arch linux and deploying to a raspberry pi and this was my problem. Compose on a pi ftw. – bsautner Jun 15 '22 at 11:26
3

While I found the accepted answer to work:

Changing

implementation(compose.desktop.currentOs)

to

implementation(compose.desktop.macos_arm64)

The documentation seems to indicate that you should just update the version of the wizard:

The Compose plugin version used in the wizard above might not be the latest. Update to the latest plugin version by editing the build.gradle.kts file and updating the version information as shown below. For the latest versions, see the latest versions site and the Kotlin site.

plugins {
    kotlin("jvm") version "1.7.20"
    id("org.jetbrains.compose") version "1.2.2"
}

Which also works, and I think should be preferred.

Quintin Balsdon
  • 5,484
  • 10
  • 54
  • 95
1

I had a similar error, but for Linux.

Cannot find libskiko-linux-x64.so.sha256, proper native dependency missing.

Updating everything to the latest version and replacing currentOs with linux_x64 made no difference, still the same error.

After explicitly adding a dependency on skiko in build.gradle.kts, it worked fine.

implementation("org.jetbrains.skiko:skiko-awt-runtime-linux-x64:0.7.69")
Jake
  • 321
  • 3
  • 12
1

I looked into the documentation of Skiko itself and found out that they suggest manually importing it the following way (the version may differ):

val osName = System.getProperty("os.name")
    val targetOs = when {
        osName == "Mac OS X" -> "macos"
        osName.startsWith("Win") -> "windows"
        osName.startsWith("Linux") -> "linux"
        else -> error("Unsupported OS: $osName")
    }

    val targetArch = when (val osArch = System.getProperty("os.arch")) {
        "x86_64", "amd64" -> "x64"
        "aarch64" -> "arm64"
        else -> error("Unsupported arch: $osArch")
    }

    val version = "0.7.70" // or any more recent version
    val target = "${targetOs}-${targetArch}"

    sourceSets {
        val jvmMain by getting {
            dependencies {
                implementation("org.jetbrains.skiko:skiko-awt-runtime-$target:$version")
                implementation(compose.desktop.currentOs)
           }
      }
}

I simply put this into the following (in the build.gradle.kts):

kotlin {}

but I think this also works when you just put it outside of it. But the implementation has to be in the dependencies {} of course . This solution solved the problem perfectly for me. I also tried to change implementation(compose.desktop.currentOs) to implementation(compose.desktop.macos_arm64) but it didn't fix it for me.

Dmitriy Popov
  • 2,150
  • 3
  • 25
  • 34
ConradB
  • 11
  • 1
0

I had a same error today on Intel x64 iMac, and solved by upgrading plugins version.
kotlin("jvm") from 1.5.31 to 1.6.10 and id("org.jetbrains.compose") from 1.0.0 to 1.1.1
FYI, it worked fine a month ago.

khcpietro
  • 1,459
  • 2
  • 23
  • 42