Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Application does not implement dagger.android.HasDispatchingActivityInjector

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

like image 324
Jordan Avatar asked Jul 19 '17 09:07

Jordan


2 Answers

It was because I hadn't added the android:name key with the value of my Application subclass to my manifest file.

like image 87
Jordan Avatar answered Oct 11 '22 16:10

Jordan


Add android:name=".MyApplication" in your manifest under application tag. Change the 'MyApplication' to the name of your application class

like image 35
Dickson the developer Avatar answered Oct 11 '22 14:10

Dickson the developer