dagger cannot inject type parameter field

As of the 2.0.1 release, Dagger 2 does support the type of injection that you're talking about. Take a look at GenericTest for all of the various permutations.


I had the same problem and got around it by adding a non-parameterized inner class and injecting into that. Then using a getter to get the injected class out.

It looks like this:

public class MainClass<T>{

   UtilityClass utility;

   public MainClass(){
       utility = new InjectorHelper().getHelper();
   }

   ...

   public static class InjectorHelper{

       @Inject
       UtilityClass utilityClass;

       public InjectorHelper(){
           Injector.getInstance().getAppComponent().inject(this);
       }

       public UtilityClass getUtilityClass(){
           return utilityClass
       }
   }
}