title: Dagger 2 : Module must be set
body: <p>I am new to Dagger 2. I have already tried to set up the same. Here is my <strong>ActivityModule</strong> :</p>
  
  <pre><code>@Module
  public abstract class ActivityModule {
      @ContributesAndroidInjector
      abstract ProductListActivity contributeProductListActivity();
  
      @ContributesAndroidInjector
      abstract ProductDetailsActivity contributeProductDetailsActivity();
  }
  </code></pre>
  
  <p>My <strong>AppModule</strong>:</p>
  
  <pre><code>@Module
  class AppModule {
  
  @Provides
      @Singleton
      RedMartProductService provideRedMartProductService() {
          ........
      }
      ........
      .......
  }
  </code></pre>
  
  <p>My <strong>AppComponent</strong>:</p>
  
  <pre><code>@Singleton
  @Component(modules = {AndroidInjectionModule.class, ActivityModule.class, AppModule.class})
  public interface AppComponent {
      @Component.Builder
      interface Builder {
          @BindsInstance
          Builder application(Application application);
  
          AppComponent build();
      }
  
      void inject(MartApplication martApp);
  }
  </code></pre>
  
  <p>My <strong>Application</strong>:</p>
  
  <pre><code>public class MartApplication extends Application implements HasActivityInjector {
  
      @Inject
      DispatchingAndroidInjector&lt;Activity&gt; dispatchingAndroidInjector;
  
      @Override
      public void onCreate() {
          super.onCreate();
          AppInjector.init(this);
      }
  
      @Override
      public DispatchingAndroidInjector&lt;Activity&gt; activityInjector() {
          return dispatchingAndroidInjector;
      }
  }
  </code></pre>
  
  <p>In <strong>AppInjector</strong>: </p>
  
  <pre><code>public class AppInjector {
  private AppInjector() {
  }
  
  public static void init(MartApplication application) {
      DaggerAppComponent.builder().application(application)
              .build().inject(application);
      application
              .registerActivityLifecycleCallbacks(new Application.ActivityLifecycleCallbacks() {
                  @Override
                  public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
                      handleActivity(activity);
                  }
  
                  ............
              });
  }
  
  private static void handleActivity(Activity activity) {
      if (activity instanceof Injectable) { //HasSupportFragmentInjector) {
          AndroidInjection.inject(activity);
      }
      if (activity instanceof FragmentActivity) {
          ((FragmentActivity) activity).getSupportFragmentManager()
                  .registerFragmentLifecycleCallbacks(
                          new FragmentManager.FragmentLifecycleCallbacks() {
                              @Override
                              public void onFragmentCreated(FragmentManager fm, Fragment f,
                                                            Bundle savedInstanceState) {
                                  if (f instanceof Injectable) {
                                      AndroidSupportInjection.inject(f);
                                  }
                              }
                          }, true);
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <p>It is throwing an exception on inject: </p>
  
  <pre><code>java.lang.RuntimeException: Unable to create application com.kaushik.myredmart.MartApplication: java.lang.IllegalStateException: com.kaushik.myredmart.di.AppModule                              must be set at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4710)
                                                   at android.app.ActivityThread.-wrap1(ActivityThread.java)
                                                   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1405)
                                                   at android.os.Handler.dispatchMessage(Handler.java:102)
                                                   at android.os.Looper.loop(Looper.java:148)
                                                   at android.app.ActivityThread.main(ActivityThread.java:5417)
                                                   at java.lang.reflect.Method.invoke(Native Method)
                                                   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
                                                   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
                                                Caused by: java.lang.IllegalStateException: com.mymart.di.AppModule must be set
                                                   at com.kaushik.myredmart.di.DaggerAppComponent$Builder.build(DaggerAppComponent.java:180)
                                                   at com.kaushik.myredmart.di.AppInjector.init(AppInjector.java:30)
                                                   at com.kaushik.myredmart.MartApplication.onCreate(MartApplication.java:28)
                                                   at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1013)
                                                   at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4707)
                                                   at android.app.ActivityThread.-wrap1(ActivityThread.java) 
                                                   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1405) 
                                                   at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                   at android.os.Looper.loop(Looper.java:148) 
                                                   at android.app.ActivityThread.main(ActivityThread.java:5417) 
                                                   at java.lang.reflect.Method.invoke(Native Method)
  </code></pre>
  
  <p>Can anyone help me to get an idea where actually the problem in my set up?</p>