Can Dagger inject an abstract activity class without injecting a child activity class?
I am trying to implement Dagger in my application and I have an instance where I need to inject a field into a class in the hierarchy of the Activity class, but the children of that class do not need any injected members. The hierarchy looks like this:
BaseActivity -> NavigationActivity -> HomePageActivity.
I am trying to enter a field in NavigationActivity, but I am getting the following exception from Dagger:
java.lang.IllegalArgumentException: No inject registered for members/com.quidsi.diapers.activity.HomePageActivity. You must explicitly add it to the 'injects' option in one of your modules.
My module looks like this
@Module(
injects = NavigationActivity.class
)
public class GestureModule {
@Provides
GestureInterface provideGestureInterface() {
return new MockDrawerGesture();
}
}
Is this possible with a dagger or do I have to inject every child of the NavigationActivity?
+3
source to share
1 answer