title: Inject dependencies into Singleton Dagger 2.11
body: <p>I have application-level scoped Singleton classes <strong>TaskRepository</strong> and <strong>AppConfig</strong>, which have dependencies of singleton types. In my activity, instance of <code>TaskRepository</code> is injected, but all its fields are null.</p>
  
  <h2>Application Class</h2>
  
  <pre><code>public class MVPApplication extends Application implements HasActivityInjector {
  
      @Inject
      DispatchingAndroidInjector&lt;Activity&gt; activityDispatchingAndroidInjector;
  
      @Inject
      TasksRepository tasksRepository;
  
      @Inject
      AppConfig appConfig;
  
      private static MVPApplication instance;
  
      @Override
      public void onCreate() {
          super.onCreate();
          instance = this;
          Realm.init(this);
          DaggerAppComponent
                  .builder()
                  .application(this)
                  .realmBuilder(Realm.getDefaultInstance())
                  .build()
                  .inject(this);
      }
  
      @Override
      public DispatchingAndroidInjector&lt;Activity&gt; activityInjector() {
          return activityDispatchingAndroidInjector;
      }
  }
  </code></pre>
  
  <h2>AppComponent</h2>
  
  <pre><code>@Singleton
  @Component(modules = {
          AndroidInjectionModule.class,
          AppModule.class,
          ActivityBindingModule.class})
  public interface AppComponent extends AndroidInjector&lt;DaggerApplication&gt; {
  
      @Component.Builder
      interface Builder {
  
          @BindsInstance
          Builder application(Application application);
  
          @BindsInstance
          Builder realmBuilder(Realm realm);
  
          AppComponent build();
      }
  
      void inject(MVPApplication application);
  
      TasksRepository getRepository();
  
      AppConfig getAppConfig();
  
  }
  </code></pre>
  
  <h2>AppModule</h2>
  
  <pre><code>@Singleton
  @Module
  public class AppModule {
  
  @Provides
  @Singleton
  TasksRepository provideTasksRepository() {
      return new TasksRepository();
  }
  
  @Provides
  @Singleton
  AppConfig provideAppConfig() {
      return new AppConfig();
  }
  }
  </code></pre>
  
  <h2>TaskRepository Class</h2>
  
  <pre><code>@Singleton
  public class TasksRepository implements RepositoryDatasource {
  
  @Inject
  Context mContext;
  
  @Inject
  AppConfig appConfig; //Singleton
  
  @Inject
  Realm realm; //Singleton
  
     //There is no constructor. Only public functions using fields
  
  }
  </code></pre>
  
  <h2>AppConfig Class</h2>
  
  <pre><code>@Singleton
  public class AppConfig {
  
      @Inject
      Context mContext;
  
     //There is no constructor. Only public functions using fields
  }
  </code></pre>
  
  <p>Please highlight my mistakes... Any help will be appreciated. Thanks!</p>