Reputation: 1042
I'm using dagger. Having the following classes:
class A {
@Inject
MyClass myClass;
}
class B extends A {
myClass.do();
}
When trying to compile this I'm getting
No injectable members on B . Do you want to add an injectable constructor?
When moving myClass to B everything compiles. Any idea what might be the problem ?
Upvotes: 2
Views: 418
Reputation: 76105
Dagger can't know all subtypes of A
so it doesn't know that it needs to generate adapters for classes like B
.
Adding a no-arg constructor with @Inject
will force the generation of code that can thus be used to perform injection on instances of B
. You can also list B.class
in the injects=
list of a module to force adapter generation.
Upvotes: 3