Please guide : org.kodein.di.Kodein$NotFoundException: No binding found
See original GitHub issueHi Team,
I am not sure if this is an issue or I am doing something wrong. Please guide.
Issue :
org.kodein.di.Kodein$NotFoundException: No binding found for bind<WeatherForecastDatabase>() with ?<CurrentWeatherFragment>().? { ? }
Registered in this Kodein container:
bind<CurrentWeatherDao>() with singleton { CurrentWeatherDao }
bind<CurrentWeatherViewModelFactory>() with provider { CurrentWeatherViewModelFactory }
bind<Unit>() with singleton { Unit }
bind<WeatherNetworkDataSource>() with singleton { WeatherNetworkDataSourceImpl }
bind<WeatherForecastRepository>() with singleton { WeatherForecastRepositoryImpl }
bind<ConnectivityInterceptor>() with singleton { ConnectivityInterceptorImpl }
bind<WeatherApiService>() with singleton { WeatherApiService }
I am using below grade dependencies,
implementation "org.kodein.di:kodein-di-generic-jvm:6.1.0"
implementation "org.kodein.di:kodein-di-framework-android-x:6.1.0"
Here is my Application class below, which I have also added in AndroidManifest.xml,
class WeatherForecastApplication : Application(), KodeinAware {
override val kodein = Kodein.lazy {
import(androidXModule(this@WeatherForecastApplication))
bind() from singleton { WeatherForecastDatabase(instance()) }
bind() from singleton { instance<WeatherForecastDatabase>().getCurrentWeatherDao() }
bind<ConnectivityInterceptor>() with singleton { ConnectivityInterceptorImpl(instance()) }
bind() from singleton { WeatherApiService(instance()) }
bind<WeatherNetworkDataSource>() with singleton { WeatherNetworkDataSourceImpl(instance()) }
bind<WeatherForecastRepository>() with singleton { WeatherForecastRepositoryImpl(instance(), instance()) }
bind() from provider { CurrentWeatherViewModelFactory(instance()) }
}
override fun onCreate() {
super.onCreate()
// init threetenbp library.
AndroidThreeTen.init(this)
}
}
And this is how I am referencing instances in Fragment,
class CurrentWeatherFragment : Fragment(), KodeinAware {
override val kodein by kodein()
private val factory: CurrentWeatherViewModelFactory by instance()
private lateinit var viewModel: CurrentWeatherViewModel
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
return inflater.inflate(R.layout.current_weather_fragment, container, false)
}
override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState)
viewModel = ViewModelProviders.of(this, factory).get(CurrentWeatherViewModel::class.java)
}
}
Issue Analytics
- State:
- Created 5 years ago
- Comments:13 (4 by maintainers)
Top Results From Across the Web
org.kodein.di.Kodein$NotFoundException: No binding found ...
Hi Team, I am not sure if this is an issue or I am doing something wrong. Please guide. Issue : org.kodein.di.Kodein$NotFoundException: No...
Read more >Kotlin Kodein NotFoundException: No binding found for bind ...
The fragment inflates and handles all interaction but the networking layer dependency is somehow missing because I receive: NotFoundException: ...
Read more >No binding found for bind<String>() with ?<Fragment>()-kotlin
You should bind the String "class" with an instance of itself inside the kodein.lazy initialization before you bind classes that use instances of...
Read more >Thanks for the tutorial. With:. I have the following exception
java.lang.RuntimeException: Unable to start activity ComponentInfo{…}: org.kodein.di.Kodein$NotFoundException: No binding found for bind ...
Read more >hey Guys I m struggling with a strange issue I m injecting S | Kodein ...
Caused by: org.kodein.di.Kodein$NotFoundException: No binding found for bind<SharedPreferences>(tag = "settings") with ?<Context>().? { ? }.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I am facing a similar issue:
No binding found for bind<Activity>() with ?<MainActivity>().? { ? } Registered in this Kodein container:
Kodein Version : 6.1.0
My Activity Code
class MainActivity : AppCompatActivity(), KodeinAware { override val kodein by kodein() private val fusedLocationProviderClient: FusedLocationProviderClient by instance() ............................... .............................. }
hi…please display your change in function into WeatherForecastDatabase…Because I have such a problem