has anyone faced this issue before, Android and IO...
# compose-desktop
k
has anyone faced this issue before, Android and IOS is working fine getting this issue only when running the desktop target. Complete output in thread
Copy code
Exception in thread "main" java.lang.NoSuchMethodError: 'void androidx.compose.ui.window.Application_desktopKt.application$default(boolean, kotlin.jvm.functions.Function3, int, java.lang.Object)'
        at MainKt.main(main.kt:11)
        at MainKt.main(main.kt)
./gradlew run Reusing configuration cache.
Task composeApprun FAILED
Exception in thread "main" java.lang.NoSuchMethodError: 'void androidx.compose.ui.window.Application_desktopKt.application$default(boolean, kotlin.jvm.functions.Function3, int, java.lang.Object)' at MainKt.main(main.kt:11) at MainKt.main(main.kt) FAILURE: Build failed with an exception. * What went wrong: Execution failed for task 'composeApprun'.
Process 'command '/opt/homebrew/Cellar/openjdk/23.0.1/libexec/openjdk.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1
* Try:
Run with --stacktrace option to get the stack trace.
Run with --info or --debug option to get more log output.
Run with --scan to get full insights.
Get more help at https://help.gradle.org.
s
This is weird, can you share your Gradle config?
k
Copy code
import org.jetbrains.compose.ExperimentalComposeLibrary
import org.jetbrains.compose.desktop.application.dsl.TargetFormat
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSetTree
import java.util.Properties

plugins {
    alias(libs.plugins.multiplatform)
    alias(libs.plugins.compose.compiler)
    alias(libs.plugins.compose)
    alias(libs.plugins.android.application)
}

kotlin {
    jvmToolchain(17)
    androidTarget {
        instrumentedTestVariant.sourceSetTree.set(KotlinSourceSetTree.test)
    }

    jvm()

    js {
        browser()
        binaries.executable()
    }

    wasmJs {
        browser()
        binaries.executable()
    }

    val opts = arrayListOf("-framework", "mvp")

    file("${rootDir}/libs/").listFiles()?.forEach {
        it.listFiles()?.forEach { file ->
            if(file.isDirectory && !file.isHidden) {
                val path = file.absolutePath
                opts.add("-F$path")
                opts.add("-rpath")
                opts.add(path)
            }
        }
    }

    listOf(
        iosX64(),
        iosArm64(),
        iosSimulatorArm64()
    ).forEach {
        it.binaries.framework {
            baseName = "ComposeApp"
            isStatic = true
        }
        it.binaries {
            getTest("DEBUG").apply {
                linkerOpts(opts)
            }
        }
    }

    sourceSets {
        commonMain.dependencies {
            implementation(compose.runtime)
            implementation(compose.foundation)
            implementation(compose.material3)
            implementation(compose.components.resources)
            implementation(compose.components.uiToolingPreview)
            implementation(libs.voyager.navigator)
            implementation(libs.voyager.koin)
            implementation(libs.voyager.tabNavigator)
            implementation(libs.voyager.transitions)
            implementation(libs.kotlinx.coroutines.core)
            implementation(libs.kotlinx.datetime)
            implementation(libs.koin.core)
            implementation(libs.koin.compose)
            implementation(libs.filekit.core)
            implementation(libs.filekit.compose)
            implementation(libs.shared.service.layer)
            implementation(libs.app.services)
            implementation(libs.adaptive.suite)
            implementation(libs.adaptive.layout)
            implementation(libs.adaptive.navigation)
        }

        commonTest.dependencies {
            implementation(libs.kotlin.test)
            @OptIn(ExperimentalComposeLibrary::class)
            implementation(compose.uiTest)
            implementation(libs.kotlinx.coroutines.test)
        }

        androidInstrumentedTest.dependencies {
            implementation(libs.androidx.uitest.junit4)
        }

        androidMain.dependencies {
            implementation(compose.uiTooling)
            implementation(libs.androidx.activityCompose)
            implementation(libs.kotlinx.coroutines.android)

            implementation(libs.androidx.camerax.core)
            implementation(libs.androidx.camerax.camera2)
            implementation(libs.androidx.camerax.lifecycle)
            implementation(libs.androidx.camerax.view)

            implementation(libs.mlkit.barcode.scanning)
            implementation(libs.mlkit.vision)

            implementation(libs.koin.android)
            implementation(libs.koin.androidx.compose)

            implementation(libs.androidx.window)
            implementation(libs.slf4j.api)
            implementation(libs.slf4j.simple)
        }

        jvmMain.dependencies {
            implementation(compose.desktop.currentOs)
            implementation(libs.kotlinx.coroutines.swing)
            implementation(libs.logback.classic)
        }

        jsMain.dependencies {
            implementation(compose.html.core)
        }

    }
}

android {
    namespace = "com.xy.z"
    compileSdk = 35
    testBuildType = "release"

    defaultConfig {
        minSdk = 21
        targetSdk = 35

        applicationId = "com.xy,z.androidApp"
        versionCode = 1
        versionName = "1.0.0"

        testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
    }

    val properties = Properties()
    properties.load(project.rootProject.file("local.properties").inputStream())

    // Remove sensitive data handling and rely on environment variables
    val keyStore = System.getenv("KEYSTORE_PATH")
    val keyStorePass = System.getenv("KEYSTORE_PASSWORD")
    val releaseKeyAlias = System.getenv("KEY_ALIAS")
    val releaseKeyPass = System.getenv("KEY_PASSWORD")

    signingConfigs {
        create("release") {
            storeFile = file(keyStore)
            storePassword = keyStorePass
            keyAlias = releaseKeyAlias
            keyPassword = releaseKeyPass
        }
    }

    buildTypes {
        release {
            ndk {
                debugSymbolLevel = "SYMBOL_TABLE"
            }
            isMinifyEnabled = false
            signingConfig = signingConfigs.getByName("release")
        }
    }
}

compose.desktop {
    application {
        mainClass = "MainKt"

        nativeDistributions {
            targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb)
            packageName = "com.xy,z.desktopApp"
            packageVersion = "1.0.0"
        }
    }
}
its pretty standard config nothing fancy going on
u
Maybe try with the jetbrains jdk
s
Yeah, the Gradle file looks all fine to me. Desktop is the only target I've never had issues with so this is puzzling. Maybe try cleaning build caches? Could be some temporary issue.
k
Tried clearing the caches didn’t work switched to zulu after try Jetbrains jdk
s
That's pretty weird Maybe try reproducing this in a minimal project, and open a YouTrack issue about it!
a
Hi @Kashismails, have you found a solution? I'm getting the same error on my project, but I didn't change any config lately. Also cleared caches and changed jdks but still the same problem.
k
Yeah i was able to fix this by removing version conflicts in compose libraries i was using material3 navigation suite which was compiled with 1.8 so i switched to older version which fixed the issue
a
it really was a version, but mine was the
androidx-activityCompose
, changed from
1.9.3
to
1.10.0
and it worked. Thanks for the tip!
k
Yeah backwards compatibility is broken in 1.8 in the parent repo of jetpack compose so we have to wait
111 Views