I've a multi-module project & I'm facing some weird issues setting up Koin DI. My project has following modules: app
, library
.
I've declared an interface in library
module & its corresponding implementation in app
module & I want to use the same in library. The code looks somewhat like:
Library Module:
interface Storage {
fun setUser(user: User)
fun getUser(): User
}
App Module:
class MyApplication : Application() {
override fun onCreate() {
super.onCreate()
startKoin(this, listOf(appModule))
}
val appModule = module {
single<Storage> { AppStorage(androidApplication()) }
}
Now, when I try to inject Storage
in library module, I get NoBeanDefFoundException
. Below is the code for the same:
class LibActivity {
private val storage by inject<Storage>()
...
}
Any ideas on what is wrong with the above code?