title: Dagger 2 not injecting in interface type
body: <p>I an trying to inject a field in an interface type which is implemented by a class.</p>
  
  <p>Here is what i have done so far.</p>
  
  <p>These are view interface:</p>
  
  <pre><code>public interface PostView extends View, ListView&lt;Post&gt;, EmptyView&lt;String&gt; {
  }
  public interface View {
  
      public void showProgressIndicator();
  
      public void hideProgressIndicator();
  
      public void onSuccess();
  
      public void onFailure();
  
      public void onFailure(String message);
  }
  
  public interface ListView&lt;E&gt; {
  
      public void onListItems(List&lt;E&gt; items,
              int pageNum,
              int pageSize,
              boolean next);
  
  }
  
  public interface EmptyView&lt;E&gt; {
  
      public void onEmpty(E e);
  
      public void onEmpty(String message);
  }
  </code></pre>
  
  <p>Components:</p>
  
  <pre><code>@Singleton
  @Component(modules = ApiModule.class)
  public interface ApiComponent {
  
      Api provideApi();
  
  }
  
  @UserScope
  @Component(dependencies = ApiComponent.class, modules = PostModule.class)
  public interface PostComponent {
  
      PostPresenter providePostPresenter();
  
      void inject(NetworkTest networkTest);
  }
  </code></pre>
  
  <p>Modules:</p>
  
  <pre><code>@Module
  public class ApiModule {
  
      private static final Logger logger = Logger.getLogger(ApiModule.class.getSimpleName());
  
      private final String baseUrl;
  
      public ApiModule(String baseUrl) {
          this.baseUrl = baseUrl;
      }
  
      @Provides
      @Singleton
      boolean provideIsLoggerEnabled() {
          logger.info("proviedIsLoggerEnabled()");
          return true;
      }
  
      @Provides
      @Singleton
      OkHttpClient provideOkHttpClient(boolean logEnabled) {
          logger.info(" provideOkHttpClient(logEnabled)");
          HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
          Interceptor requestInterceptor = new Interceptor() {
              @Override
              public Response intercept(Chain chain) throws IOException {
                  return chain.proceed(chain.request());
              }
          };
          interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
          OkHttpClient.Builder builder = new OkHttpClient.Builder()
                  .addInterceptor(requestInterceptor)
                  .addNetworkInterceptor(interceptor);
          return builder.build();
      }
  
      @Provides
      @Singleton
      Api provideApi(OkHttpClient okHttpClient) {
          logger.info("provideApi");
          Retrofit retrofit = new Retrofit.Builder()
                  .client(okHttpClient)
                  .baseUrl(baseUrl)
                  .addConverterFactory(GsonConverterFactory.create())
                  .build();
          return retrofit.create(Api.class);
      }
  
  }
  
  @Module
  public class PostModule {
  
      private static final Logger logger = Logger.getLogger(PostModule.class.getSimpleName());
      private final PostView postView;
  
      public PostModule(PostView postView) {
          this.postView = postView;
      }
  
      @Provides
      @UserScope
      PostService providePostService(Api api) {
          logger.info("Provider post with api now");
          return new PostService(api);
      }
  
      @Provides
      @UserScope
      PostPresenter providePostPresenter(PostService service) {
          logger.info("Providing presenter with service now");
          return new PostPresenter(postView, service);
      }
  }
  </code></pre>
  
  <p>Presenter:</p>
  
  <pre><code>public class PostPresenter extends AbstractPresenter {
  
      private static final Logger logger = Logger.getLogger(PostPresenter.class.getSimpleName());
      private PostView postView;
      private PostService postService;
  
      public PostPresenter(PostView postView, PostService postService) {
          this.postView = postView;
          this.postService = postService;
      }
  
      @Override
      protected View getView() {
          logger.info("Getting view");
          throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
      }
  
      public void getPosts() {
          logger.info("Getting posts ");
          Call&lt;List&lt;Post&gt;&gt; posts = this.postService.getPosts();
          postView.showProgressIndicator();
          posts.enqueue(new Callback&lt;List&lt;Post&gt;&gt;() {
  
              @Override
              public void onResponse(Call&lt;List&lt;Post&gt;&gt; call, Response&lt;List&lt;Post&gt;&gt; rspns) {
                  postView.onListItems(rspns.body(), 1, 25, true);
                  postView.hideProgressIndicator();
                  postView.onSuccess();
              }
  
              @Override
              public void onFailure(Call&lt;List&lt;Post&gt;&gt; call, Throwable thrwbl) {
                  onApiCallError(thrwbl);
                  postView.hideProgressIndicator();
              }
          });
      }
  }
  
  public abstract class AbstractPresenter {
  
      private static final Logger logger = Logger.getLogger(AbstractPresenter.class.getSimpleName());
  
      protected abstract View getView();
  
      /*
       * General indication whether api call stated or not.
       */
      protected void onApiCallStart() {
          logger.info("Api call started");
          View v = getView();
          if (v != null) {
              v.showProgressIndicator();
          }
      }
  
      protected void onApiCallEnd() {
          logger.info("Api call finished");
          View v = getView();
          if (v != null) {
              v.hideProgressIndicator();
          }
      }
  
      /*
       * General error handling 
       */
      protected void onApiCallError(Throwable e) {
          logger.info("Api call terminated with error");
          View v = getView();
          if (v != null &amp;&amp; e != null) {
              v.onFailure(e.getMessage());
          }
      }
  }
  </code></pre>
  
  <p>NetworkTest:</p>
  
  <pre><code>public class NetworkTest implements PostView {
  
      private static final Logger logger = Logger.getLogger(NetworkTest.class.getSimpleName());
  
      private PostComponent component;
      @Inject
      PostPresenter presenter;
  
      public NetworkTest(ApiComponent apiComponent) {
          component = DaggerPostComponent.builder()
                  .apiComponent(apiComponent)
                  .postModule(new PostModule(this))
                  .build();
      }
  
      public void init() {
          component.inject(this);
      }
  
      void showPosts() {
          if (presenter != null) {
              logger.info("Hurray it worked");
              presenter.getPosts();
          } else {
              logger.warning("Alas it failed");
          }
      }
  
      @Override
      public void showProgressIndicator() {
          logger.info("Show progress indicator here");
      }
  
      @Override
      public void hideProgressIndicator() {
          logger.info("Hide progress indicator here");
      }
  
      @Override
      public void onSuccess() {
          logger.info("Api calls successfull");
          System.exit(0);
      }
  
      @Override
      public void onFailure() {
          logger.warning("Api call failure");
          System.exit(0);
      }
  
      @Override
      public void onFailure(String message) {
          logger.warning(message);
          System.exit(0);
      }
  
      @Override
      public void onListItems(List&lt;Post&gt; items, int pageNum, int pageSize, boolean next) {
          logger.info("List received is: " + new Gson().toJson(items));
      }
  
      @Override
      public void onEmpty(String e) {
          throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
      }
  
      public static void main(String[] args) {
          ApiComponent apiComponent = DaggerApiComponent.builder()
                  .apiModule(new ApiModule("https://jsonplaceholder.typicode.com/"))
                  .build();
  
          NetworkTest networkTest = new NetworkTest(apiComponent);
          networkTest.init();
          networkTest.showPosts();
      }
  
  }
  </code></pre>
  
  <p>My Problem is when i try to use</p>
  
  <pre><code>void inject(NetworkTest networkTest); //It works
  void inject(PostView postView); //Doesn't work
  </code></pre>
  
  <p>I want that <code>PostPresenter</code> should get Injected in any class who is implementing <code>PostView</code>.</p>
  
  <p>But when i do this <code>@Inject</code> field return null.
  Does anyone have any clue about this.</p>