hey Guys! I’m struggling with a strange issue! I’m injecting SharedPref all around the app but sometimes, I’m getting this error.
org.kodein.di.Kodein$NotFoundException: No binding found for bind<SharedPreferences>() with ? { ? }
Available bindings for this type:
module androidModule {
bind<SharedPreferences>() with contexted<Context>().factory { String -> SharedPreferences }
bind<SharedPreferences>() with contexted<Context>().provider { SharedPreferences }
}
Registered in this Kodein container:
module analyticsModule {
bind<Analytics>() with singleton { AnalyticsImpl }
}
....
module apiM
I tried to solve it by manually bind SharedPreferences, without any luck
bind<SharedPreferences>() with singleton { PreferenceManager.getDefaultSharedPreferences(instance()) }
but what I eventually do (as I need Android Context as well for injection) is to use androidXmodule in the Application object. However the issue is still coming
override val kodein = Kodein.lazy {
import(androidXModule(this@MainApplication))
import(generalModule)
import(repositoryModule)
import(viewModelModule)
import(appSettingsModule)
import(apiModule)
import(useCaseModule)
import(analyticsModule)
import(locationModule)
import(dataSourceModule)
}
Please help me! I can’t find the solution