Hi, I'm trying to setup Koin in my project followi...
# touchlab-tools
l
Hi, I'm trying to setup Koin in my project following KampKit. There are these two lines in common Koin:
Copy code
val doOnStartup = koin.get<() -> Unit>() // doOnStartup is a lambda which is implemented in Swift on iOS side
doOnStartup.invoke()
When I try running my Android project, it crashes with org.koin.core.error.NoBeanDefFoundException: No definition found for class:'kotlin.jvm.functions.Function0'. Check your definitions! If I remove those two lines, it runs fine. I see that I can remove this doOnStartup both from common Koin and iOS code, because in KampKit it doesn't do anything important. But why doesn't it work in my project, but in KampKit it does?
r
doOnStartup
is just a sample to demo how you might inject arbitrary platform-specific logic. It's not actually doing anything important so you can definitely safely remote it. As to why it's not working for you on Android, the error indicates that it's looking for something that's not there. Are you missing a
() -> Unit
definition on the Android side? KaMPKit passes it here: https://github.com/touchlab/KaMPKit/blob/master/app/src/main/java/co/touchlab/kampkit/android/MainApp.kt#L24-L26
l
That's it, I left this line out 😕 Thank you, you saved my evening! 🙂
👍 3