I use Dagger2 for DI in my android application. I found that I have to write inject method for every class that uses @Inject field. Is there a way that I can just inject the
It cannot be done right now. Explanation by Gregory Kick (from here):
Here's how members injection methods work:
- You can make a members injection method for any type that has
@Inject
anywhere in its class hierarchy. If it doesn't, you'll get an error.- All
@Inject
ed members in the entire type hierarchy will be injected: the argument type and all supertypes.- No members will be
@Inject
ed for subtypes of the argument type.
This issue was discussed here and here, follow up these for updates. But it is unlikely to change soon, cause Dagger 2 is close to release.