InsertKoinIO / koin

Koin - a pragmatic lightweight dependency injection framework for Kotlin & Kotlin Multiplatform
https://insert-koin.io
Apache License 2.0
8.97k stars 710 forks source link

[3.6.0-Beta4] Didn't find class "org.koin.compose.stable.StableHoldersKt" #1879

Open AlexanderEggers opened 4 months ago

AlexanderEggers commented 4 months ago

Describe the bug When running my app (CMP v1.6.10 + Kotlin v2 + Voyager 1.1.0-beta01) after updating to 3.6.0-Beta4, I get the following exception on Android:

Caused by: java.lang.ClassNotFoundException: Didn't find class "org.koin.compose.stable.StableHoldersKt"

Downgrading to the latest stable 3.5.x resolves the issue for me.

To Reproduce Unclear about the project structure which is needed to reproduce this issue. In my case it is sufficient to just update to the latest 3.6.0 beta version to reproduce this crash.

Expected behavior No crash.

Koin module and version: 3.6.0-Beta4

Snippet or Sample project to help reproduce

Cuyer commented 4 months ago

I am having the same issue after upgrading to 3.6.0-Beta4. When looking at the stacktrace, the error comes from Voyager in my case.

Shusshu commented 4 months ago

Update the code you took from voyager to the following:


public inline fun <reified T : ScreenModel> Screen.koinScreenModel(
    qualifier: Qualifier? = null,
    scope: Scope = currentKoinScope(),
    noinline parameters: ParametersDefinition? = null
): T {
    val st = parameters?.let { rememberUpdatedState(parameters) }
    val tag = remember(qualifier, scope) { qualifier?.value }
    return rememberScreenModel(tag = tag) {
        scope.get(qualifier, st?.value)
    }
}

@Composable
public inline fun <reified T : ScreenModel> Navigator.koinNavigatorScreenModel(
    qualifier: Qualifier? = null,
    scope: Scope = currentKoinScope(),
    noinline parameters: ParametersDefinition? = null
): T {
    val st = parameters?.let { rememberUpdatedState(parameters) }
    val tag = remember(qualifier, scope) { qualifier?.value }
    return rememberNavigatorScreenModel(tag = tag) {
        scope.get(qualifier, st?.value)
    }
}
arnaudgiuliani commented 2 months ago

Look at 4.0-RC1

wlmirand commented 1 month ago

I tested the latest Voyager with the Koin 4.0 RC1 and the crash still happens. It happens only when running my app on iOS (Android works fine)

terrakok commented 1 month ago

Desktop app doesn't work as well with the same error koin = "4.0.0-RC1" voyager = "1.1.0-beta02"

terrakok commented 1 month ago

I guess the problem is inside the Voyager. It uses

koin = "3.5.3"
koin-compose = "1.1.2"

cc @DevSrSouza

arnaudgiuliani commented 2 weeks ago

let me know 👍