Hi all! I'm using kodein with DIGlobalAware approa...
# kodein
Hi all! I'm using kodein with DIGlobalAware approach. Few days later I've updated app dependencies from 5 version to 7... And after that i hav problems with getting bindings from androiXModules.. For me it's android system services as SharedPreferences or InputMethodManager. Logs from kodein show me that this binding is in container, but when i try to inject it in my class or retrieve it from DIGlobalAware i get DI@NotFoundException
there is start of kodein logs
java.lang.RuntimeException: Unable to create application ru.syrupmg.flighttaxi.App: org.kodein.di.DI$NotFoundException: No binding found for android.content.SharedPreferences Available bindings for this type: module ⁣androidModule { bind<android.content.SharedPreferences> { contexted<android.content.Context>().factory { kotlin.String -> android.content.SharedPreferences } } bind<android.content.SharedPreferences> { contexted<android.content.Context>().provider { android.content.SharedPreferences } } }
How do you try to retrieve your SharedPreferences?
Copy code
class AppSettingsServiceImpl(private val context: Context, private val preferences: SharedPreferences) : AppSettingsService
This is constructor of my service classs
Copy code
bind<AppSettingsService>() with singleton { AppSettingsServiceImpl(instance(App), instance()) }
this is my binding.. Application crashes while building DI.module.
FYI.. This problem is repeat for other android systemServices from adroidX module/
I have the same problem for
(No binding found for ConnectivityManager), looking at it.
As a workaround:
Copy code
private fun ConnectivityManager(
    context: Context,
): ConnectivityManager =
    context.getSystemService(Application.CONNECTIVITY_SERVICE) as ConnectivityManager

private fun SharedPreferences(
    context: Context,
): SharedPreferences =

class MyApp : Application(), DIAware {
    override val di by DI.lazy {
        bindProvider {  SharedPreferences(instance()) }
        bindProvider { ConnectivityManager(instance()) }
Not sure what the root cause is, will investigate and report a bug if I find it.
Can you share a minimal reproducer ?