Since Kodein version 6.x we get this error when bindings are examined:
Copy code
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.wecenergygroup.wps.debug/com.wec.weenergies.screens.landing.LandingActivity}: org.kodein.di.Kodein$NotFoundException: 3 bindings found that match bind<Context>() with ?<LandingActivity>().? { ? }:
module Context {
bind<Context>() with singleton { Application }
}
module WeEnergiesApplication {
bind<WeEnergiesApplication>() with singleton { WeEnergiesApplication }
}
module androidModule {
bind<Application>() with provider { Application }
}
The first two are under our app’s control, the last one is from Kodein’s
androidModule
.
What would be the ‘best’ way to solve this ambiguity? Using ‘sub-type’ bindings or is there a less verbose way?
s
salomonbrys
04/17/2019, 10:50 PM
I would use tags
s
streetsofboston
04/17/2019, 11:00 PM
Thank you!
Still, using tags is easy to forget where
instance()
is being called.
Is there way to bind to a concrete type and not to a sub-type?
s
salomonbrys
04/18/2019, 5:20 AM
You can bind any type, including concrete types.
s
streetsofboston
04/18/2019, 4:22 PM
@salomonbrys
Thank you!
The stack-trace didn’t happen in version 5.x but started happening in 6.x.
We are wondering why and what would be the best/easiest way to fix it.