Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dagger2 dagger.android.* classes does not exist

I'm adding Dagger2 to my Android app following the instructions from the official docs. I've used Dagger and Dagger2 before, it seems like Google has revamped the implementation for Android as of the following quote;

The classes in dagger.android offer one approach to simplify this pattern.

...

Next, make your Application implement HasDispatchingActivityInjector and @Inject a DispatchingAndroidInjector to return from the activityInjector() method:

It looks awesome, but I can't find the package dagger.android anywhere, nor do I find anything when I look through the repository, HasDispatchingActivityInjector gives no hits on Google at all. Where are these classes described in the docs?

I can find all the other Dagger2 classes alright (Module etc.) so the libs are there.

My dagger dependencies from build.gradle:

compile 'com.google.dagger:dagger:2.9'
compile 'com.google.dagger:dagger-android:2.9'
annotationProcessor 'com.google.dagger:dagger-compiler:2.9'
like image 255
Pär Nils Amsen Avatar asked Feb 17 '17 17:02

Pär Nils Amsen


1 Answers

The code is listed in the google/dagger Github repository, under the java/dagger/android subtree, committed four days ago (Feb 13, 2017 3:58PM PST). This includes HasDispatchingActivityInjector.

Your gradle file is correct: Dagger's Android extensions are available through an adjacent dagger-android package, not through the main dagger package. See Maven's Dagger packages for more details.

EDIT: As of yesterday the dagger.android Android helpers are released in version 2.10-rc1

like image 189
Jeff Bowman Avatar answered Oct 25 '22 22:10

Jeff Bowman