1

I created an application with Kotlin Multiplatform, for desktop (only).

The application works great when I do ./gradlew run but fails when I do ./gradlew runDistributable giving:

Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/net/httpserver/HttpHandler
    at com.google.api.client.extensions.jetty.auth.oauth2.LocalServerReceiver$Builder.build(LocalServerReceiver.java:222)
    at GPhotoClientProvider.getUserCredentials(GPhotoClientProvider.kt:106)
    at GPhotoClientProvider.createClient(GPhotoClientProvider.kt:46)
    at SlideshowService.<clinit>(SlideshowService.kt:10)

and in my build.gradle.kts I have:

import org.jetbrains.compose.desktop.application.dsl.TargetFormat


plugins {
    kotlin("multiplatform").version("1.8.0")
    id("org.jetbrains.compose")
}

group = "org.myapp"
version = "1.0-SNAPSHOT"

repositories {
    google()
    mavenCentral()
    maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
}

kotlin {
    jvm {
        jvmToolchain(11)
        withJava()
    }
    sourceSets {
        val ktorVersion = "2.3.1"
        val jvmMain by getting {
            dependencies {
                implementation(compose.desktop.currentOs)
                implementation("org.slf4j:slf4j-simple:1.7.36")

                implementation("com.google.oauth-client:google-oauth-client:1.34.1")
                implementation("com.google.oauth-client:google-oauth-client-java6:1.34.1")
                implementation("com.google.oauth-client:google-oauth-client-jetty:1.34.1")

                implementation("com.google.api-client:google-api-client:2.2.0")
                implementation("com.google.photos.library:google-photos-library-client:1.7.3")

                implementation("io.ktor:ktor-client-java:$ktorVersion")
                implementation("io.ktor:ktor-client-cio:$ktorVersion")
                implementation("io.ktor:ktor-client-logging:$ktorVersion")

                implementation("io.github.g0dkar:qrcode-kotlin-jvm:3.3.0")
            }

        }
        val jvmTest by getting
    }
}

compose.desktop {
    application {
        mainClass = "MainKt"
        nativeDistributions {
            targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb)
            packageName = "myApp"
            packageVersion = "1.0.0"
        }
    }
}


On Google website for client API I just found the Maven instructions, which I tried to follow. I'm not very familiar with Gradle or Kotlin Multiplatform, and the documentation for desktop is not so great.

Phil Dukhov
  • 67,741
  • 15
  • 184
  • 220
zambotn
  • 735
  • 1
  • 7
  • 20
  • just to say that i tried to add ` implementation("com.sun.net.httpserver:http:20070405")` in order to provide the missing class (even is shouldn't be needed since it's executing anyway with `run`) but still doesn't work. This time it breaks with a runtime error and exit code 13 – zambotn Jul 28 '23 at 13:45
  • If you've solved your problem and now have a different one, you should ask a new question and provide all the relevant details. – Jorn Aug 04 '23 at 07:19
  • I didn't solve the problem... My issue is related to missing documentation on what happens when I execute the Kotlin multiplatform plugin... Why there is no issue when I do run and I do have missing dependencies when I do runDistributable? – zambotn Aug 04 '23 at 11:13
  • Not sure if that helps, but check out this issue. https://stackoverflow.com/questions/68561300/kotlin-multiplatform-library-unresolved-dependency-at-runtime/71355860 – Serge Sep 01 '23 at 20:58

0 Answers0