Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.lang.NoSuchMethodError when adding FileKit Compose #179

Open
Fifteen15Studios opened this issue Dec 29, 2024 · 1 comment
Open

java.lang.NoSuchMethodError when adding FileKit Compose #179

Fifteen15Studios opened this issue Dec 29, 2024 · 1 comment

Comments

@Fifteen15Studios
Copy link

After I add implementation("io.github.vinceglb:filekit-compose:0.8.8") to my build.gradle, I get this when I run it:

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)'

Gradle builds properly, but the app no longer runs. I immediately get this error. The non-compose version doesn't cause this error. With the non-compose version, Gradle builds and the app still runs. I didn't try to actually implement it, since I'm using compose, but it at least does not cause this error to immediately occur.

I was able to fix this by adding implementation("androidx.compose.ui:ui:1.7.6), which would likely already be there if I was building for Android. But my project is using KMM but is only building a server-side app, so I'm only importing the desktop compose stuff.

After adding that implementation I get this error:

Exception in thread "main" kotlin.NotImplementedError: Implemented only in JetBrains fork. Please use org.jetbrains.compose.runtime:runtime package instead.

To get rid of this, I had to add

implementation("androidx.compose.ui:ui:1.7.6")

and remove

implementation(compose.ui)

I added a few more to get rid of other errors:

implementation("org.jetbrains.compose.runtime:runtime:1.7.3")
implementation("org.jetbrains.compose.ui:ui-text:1.7.3")

But I left off at this error:

Exception in thread "main" kotlin.NotImplementedError: Implemented only in JetBrains fork. Please use org.jetbrains.compose.ui:ui-util package instead.

I added implementation("org.jetbrains.compose.ui:ui-util:1.7.3"), but am still getting this error. (I'm sure there's something I need to remove that is conflicting - like it was with androidx.compose.ui:ui:1.7.6 and implementation(compose.ui) - but I'm not sure what to remove.)

TLDR; I still can't get the compose version to work without Android

@vinceglb
Copy link
Owner

Hi @Fifteen15Studios! Thanks for creating this issue.

Can you reproduce your problem with the sample-compose project?
https://github.com/vinceglb/FileKit/tree/main/samples/sample-compose

Actually, in KMP, it's recommended to use JetBrains implementation of Compose like below:

kotlin {
    jvm("desktop")

    sourceSets {
        commonMain.dependencies {
            // Compose
            implementation(compose.runtime)
            implementation(compose.foundation)
            implementation(compose.material3)
            implementation(compose.ui)
            implementation(compose.components.resources)
            implementation(compose.components.uiToolingPreview)

            // FileKit
            implementation("io.github.vinceglb:filekit-compose:0.8.8")
        }
    }
}

You're probably using some dependencies that are not compatible with the JVM target?

To help you set up FileKit on a Compose project, you can follow this sample-compose example project. Here is the sample-compose build.gradle.kts file: https://github.com/vinceglb/FileKit/blob/main/samples/sample-compose/composeApp/build.gradle.kts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants