title: Dagger 2 component dependencies
body: <p>Is it possible to inject something into a module?</p>
  
  <p>I have 2 base modules / components:</p>
  
  <pre class="lang-java prettyprint-override"><code>@Component(modules = {OkHttpModule.class})
  public interface OkHttpComponent extends AppComponent {
  
      OkHttpClient provideOkHttpClient();
  }
  
  @Module
  public class OkHttpModule {
  
      @Provides
      OkHttpClient provideOkHttpClient() {
  
          return mHttpClient;
      }
  }
  </code></pre>
  
  <pre class="lang-java prettyprint-override"><code>@Component(modules = {GsonModule.class})
  public interface GsonComponent extends AppComponent {
  
      Gson provideGson();
  }
  
  @Module
  public class GsonModule {
  
      @Provides
      Gson provideGson() {
  
          return mGson;
      }
  }
  </code></pre>
  
  <p>With this modules / components I want to create a 3rd module:</p>
  
  <pre class="lang-java prettyprint-override"><code>@Component(dependencies = {OkHttpComponent.class, GsonComponent.class}, 
             modules = {RetrofitModule.class})
  public interface RetrofitComponent extends AppComponent {
  
      API provideAPI();
  }
  
  @Module
  public class RetrofitModule {
  
      @Inject OkHttpClient mHttpClient;
      @Inject Gson         mGson;
  
      @Provides
      VeentsMeAPI provideVeentsMeAPI() {
  
          return mVeentsMeAPI;
      }
  }
  </code></pre>
  
  <p>But <code>mHttpClient</code> and <code>mGson</code> are not injected. Is it possible to inject something into a module? And if yes how?</p>
  
  <p>I create the components like this:</p>
  
  <pre class="lang-java prettyprint-override"><code>okHttpComponent = DaggerOkHttpComponent.builder()
          .okHttpModule(new OkHttpModule(this))
          .build();
  
  gsonComponent = DaggerGsonComponent.builder()
          .gsonModule(new GsonModule())
          .build();
  
  retrofitComponent = DaggerRetrofitComponent.builder()
          .retrofitModule(new RetrofitModule())
          .okHttpComponent(okHttpComponent)
          .gsonComponent(gsonComponent)
          .build();
  </code></pre>