Hi, I'm migrating from Kodein to Koin in Compose M...
# koin
a
Hi, I'm migrating from Kodein to Koin in Compose Multiplatform project with Wasm support Today I stuck with this error
Copy code
2024-05-23 00:49:44.444 [main] DEBUG [Koin] - Started 29 definitions in 0.796209 ms
2024-05-23 00:49:44.444 [main] DEBUG [Koin] - Create eager instances ...
2024-05-23 00:49:44.444 [main] DEBUG [Koin] - Created eager instances in 0.11425 ms
2024-05-23 00:49:44.445 [main] DEBUG [Koin] - Create eager instances ...
2024-05-23 00:49:44.445 [main] DEBUG [Koin] - Created eager instances in 0.002666 ms
Exception in thread "main" java.lang.NoSuchMethodError: 'io.ktor.events.Events io.ktor.server.application.ApplicationEnvironment.getMonitor()'
	at org.koin.ktor.plugin.KoinPluginKt.setupMonitoring(KoinPlugin.kt:54)
	at org.koin.ktor.plugin.KoinPluginKt$Koin$2.invoke(KoinPlugin.kt:38)
	at org.koin.ktor.plugin.KoinPluginKt$Koin$2.invoke(KoinPlugin.kt:35)
	at io.ktor.server.application.CreatePluginUtilsKt.setupPlugin(CreatePluginUtils.kt:300)
	at io.ktor.server.application.CreatePluginUtilsKt.createPluginInstance(CreatePluginUtils.kt:269)
	at io.ktor.server.application.CreatePluginUtilsKt.access$createPluginInstance(CreatePluginUtils.kt:1)
	at io.ktor.server.application.CreatePluginUtilsKt$createApplicationPlugin$2.install(CreatePluginUtils.kt:90)
	at io.ktor.server.application.CreatePluginUtilsKt$createApplicationPlugin$2.install(CreatePluginUtils.kt:83)
when tried to add Koin to Ktor server
Copy code
private fun connectServer() = embeddedServer(
    factory = Netty,
    port = 8080,
    module = { setApplicationModule() } // configureKoin here
).start(wait = true)

internal fun Application.configureKoin() {
    install(Koin) {                    // <--- Error here
        slf4jLogger(level = Level.DEBUG)
        modules(serverModules)
    }
}
I use these versions
Copy code
koin = "3.6.0-wasm-alpha2"
ktor = "3.0.0-wasm2"
ktor-plugin = "3.0.0-beta-1"

koin = { module = "io.insert-koin:koin-core", version.ref = "koin" }
koin-ktor = { module = "io.insert-koin:koin-ktor", version.ref = "koin" }
koin-ktor-logger = { module = "io.insert-koin:koin-logger-slf4j", version.ref = "koin" }
Can you please tell me what did I wrong? Thanks
p
Seems to be complaining about a missing plug-in for Application monitoring or so. Where the ApplicationEnvironment is at. Or maybe this plug-in dependency is applied but not the version with that specific signature
a
I guess it's about version incompatibility, but I can't figure out what's exactly wrong
Because it worked with Kodein
r
Try using latest beta instead of alpha version.
a
@Robert Jaros Does it work with
wasm
?
Copy code
> Could not resolve all dependencies for configuration ':app_presentation:wasmJsCompileClasspath'.
   > Could not find io.insert-koin:koin-compose:3.6.0-Beta4.
Copy code
koin = "3.6.0-Beta4"
koin-compose = "1.2.0-Beta4"

koin = { module = "io.insert-koin:koin-core", version.ref = "koin" }
koin-ktor = { module = "io.insert-koin:koin-ktor", version.ref = "koin" }
koin-ktor-logger = { module = "io.insert-koin:koin-logger-slf4j", version.ref = "koin" }
koin-compose = { module = "io.insert-koin:koin-compose", version.ref = "koin-compose" }
koin-android = { module = "io.insert-koin:koin-androidx-compose", version.ref = "koin" }
Changed
koin-compose
version, but still getting an error
TL;DR - Koin doesn't support Ktor v3+ now, so I had to downgrade
ktor-server
deps:
Copy code
ktor = "2.3.11"
ktor-plugin = "2.3.11"
🎉 1
thank you color 1