title: Dagger activity graph and separated modules
body: <p>I have an Android application and I'm trying to use dagger. I decided to use a global graph + activity graphs. I have three modules:</p>
  
  <p>AndroidModule</p>
  
  <pre><code>@Module(library = true)
  public class AndroidModule {
  
    private final MApplication mApplication;
  
    public AndroidModule(MyApplication application) {
      mApplication = application;
    }
  
    @Provides @Singleton @ForApplication Context provideApplicationContext() {
      return mApplication;
    }
  }
  </code></pre>
  
  <p>MyAppModules</p>
  
  <pre><code>@Module(
      injects = {
              MainActivity.class,
              AddFragment.class,
              AddMapFragment.class,
              MyActivity.class,
              ListFragment.class,
              MyMapFragment.class,
              RetainFragment.class,
              SingleActivity.class,
              UserActivity.class,
              UserLoginFragment.class,
              UserProfileActivity.class,
              UserProfileFragment.class,
              UserRegisterFragment.class,
              WelcomeFragment.class
      },
      complete = false,
      library = true,
      includes = ActivityModule.class
  )
  public class MyAppModule {
  
    private final Bus mBus = new Bus();
  
    @Provides @Singleton Bus provideBus() {
      return mBus;
    }
  
    @Provides @Singleton
    RequestQueue provideRequestQueue(@ForApplication Context context) {
      return Volley.newRequestQueue(context);
    }
  
    @Provides @Singleton Api provideApi(RequestQueue queue) {
      return new AppApi(queue);
    }
  
    @Provides Logger provideLogger() {
      return new MyLogger();
    }
  }
  </code></pre>
  
  <p>ActivityModule</p>
  
  <pre><code>@Module(
      complete = false,
      library = true
  )
  public class ActivityModule {
  
    private BaseActivity mActivity;
    public ActivityModule() {}
  
    public ActivityModule(BaseActivity activity) {
      mActivity = activity;
    }
  
    @Provides @Singleton @ForActivity Context provideActivityContext() {
      return mActivity;
    }
  
    @Provides @Singleton LocationClientFactory provideLocationClientFactory() {
      return new LocationClientFactory(mActivity);
    }
  }
  </code></pre>
  
  <p>I had to use include on <code>MyAppModule</code> for the <code>ActivityModule</code>, without it, the application crashed saying it could find a constructor on <code>Context</code> and couldn't inject the <code>Activity</code>'s <code>Context</code>. </p>
  
  <p>Is the graph configured correctly? I'm adding the modules to the graph in the <code>Application</code> and in a <code>BaseActivity</code> and I thought it was enough and I didn't need the include, but I'm not sure I completly understand the configuration process of this.</p>
  
  <p><strong>Edit</strong></p>
  
  <p>Like this, dagger gives no errors but if I try to inject an <code>Activity</code> <code>Context</code>, at runtime it's <code>null</code>.</p>