Closed SeleznevAM closed 6 months ago
I reproduced your issue.
I don't know when this has been changed, but as you can see in the logs all the Android stuff are contexted
.
This means that they must be retrieved on a given context. As we are on Android, they are bound to a Android Context
.
So when binding your AppSettingsService
you need to specify this context. like:
val myModule by DI.Module {
bindSingleton<AppService> {
DefaultAppService(
sharedPreferences =
on(instance<Context>())
.instance<String, SharedPreferences>(arg = "myPref")
)
}
}
What's important here, is on(instance<Context>())
.
Hope this helps.
Thank you, very match!!! It's helped me %))
I migrated from kodein version 5 to verson 7 And after migrating i started to get DI$NotFoundException when i try to get SharedPreferences or for example ConnectivityManager though di container containes binding for this type. I use DIGlobalAware approach -add my module to DI.global
with(DI.global) { addImport(Services.layer, true) }
-import androidXModule to mu own module
-class signature where i using SharedPreferences
class AppSettingsServiceImpl(private val context: Context, private val preferences: SharedPreferences) : AppSettingsService {...}
Container has binding for simpleSharedPreferences and named ShredPreferences but when i try to retrive dependency from container i have exeption