I have a subclass of Application that I am conforming to HasDispatchingActivityInjector, but when I try and run my app it will crash, saying:
Unable to start activity ComponentInfo{com.test.testing/com.test.testing.ui.main.MainActivity}: java.lang.RuntimeException: android.app.Application does not implement dagger.android.HasDispatchingActivityInjector
This is my Application subclass:
class MyApplication : Application(), HasDispatchingActivityInjector {
@Inject
lateinit var dispatchingAndroidInjector: DispatchingAndroidInjector<Activity>
override fun onCreate() {
super.onCreate()
DaggerAppComponent.create().inject(this)
}
override fun activityInjector(): DispatchingAndroidInjector<Activity> {
return dispatchingAndroidInjector
}
Has anyone else experienced this error before?
Thanks
It was because I hadn't added the android:name key with the value of my Application subclass to my manifest file.
Add android:name=".MyApplication"
in your manifest under application tag.
Change the 'MyApplication' to the name of your application class
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With