Dagger2: how to inject retrofit module in presenter class











up vote
1
down vote

favorite












Dagger2 learning is still difficult and am trying to learn. Have setup a project using new dagger android to avoid injecting inside activity class. So far it's working but need to use retrofit injected in presenter class. Added retrofit module in AppComponent but apiService class method getting null when call from presenter class. Need to know how to inject properly.



AppComponent.java



@Singleton
@Component(modules = {
/* Use AndroidInjectionModule.class if you're not using support library */
AndroidSupportInjectionModule.class,
AppModule.class,
BuildersModule.class,
RetrofitModule.class})
public interface AppComponent {

@Component.Builder
interface Builder {
@BindsInstance
Builder application(BaseApplication application);

Builder retrofitModule(RetrofitModule retrofitModule);

AppComponent build();
}

void inject(BaseApplication app);
}


AppModule.java



@Module
class AppModule {

@Provides
Context provideContext(BaseApplication application) {
return application.getApplicationContext();
}
}


BuildersModule.java



@Module
public abstract class BuildersModule {

@ContributesAndroidInjector(modules = {SplashViewModule.class, SplashModule.class})
abstract SplashActivity bindSplashActivity();

// Add bindings for other sub-components here
}


BaseApplication.java



public class BaseApplication extends Application implements HasActivityInjector {

@Inject
DispatchingAndroidInjector<Activity> dispatchingAndroidInjector;

@Override
public void onCreate() {
super.onCreate();

//configure timber for logging
if (BuildConfig.DEBUG) {
Timber.plant(new Timber.DebugTree());
}

DaggerAppComponent
.builder()
.application(this)
.retrofitModule(new RetrofitModule())
.build()
.inject(this);
}


@Override
public AndroidInjector<Activity> activityInjector() {
return dispatchingAndroidInjector;
}
}


RetrofitModule.java



@Module
public class RetrofitModule {

//get retrofit instance
@Singleton
@Provides
public UserAuthService getRestService() {

Gson gson = new GsonBuilder()
.setLenient()
.create();

Retrofit retrofit = new Retrofit.Builder()
.baseUrl(ApiConstants.BASE_URL)
.addConverterFactory(GsonConverterFactory.create(gson))
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
.client(getOkHttpClient())
.build();

return retrofit.create(UserAuthService.class);
}
}


UserAuthService.java



public interface UserAuthService {

@GET("v2/5be345062f00006b00ca22c4")
Observable<Example> getExampleResponse();
}


SplashModule.java



@Module
public class SplashModule {

@Provides
SplashPresenter provideSplashPresenter(SplashView splashView) {
return new SplashPresenter(splashView);
}
}


SplashViewModule.java



@Module
public abstract class SplashViewModule {

@Binds
abstract SplashView provideSplashView(SplashActivity splashActivity);

}


SplashPresenter.java



class SplashPresenter extends BasePresenter<SplashView> {


@Inject
@Named(ValueConstants.MAIN_THREAD)
Scheduler mMainThread;

@Inject
@Named(ValueConstants.NEW_THREAD)
Scheduler mNewThread;

@Inject
UserAuthService userAuthService;

SplashPresenter(SplashView view) {
super(view);
}

//test purpose
public void sayHello() {

userAuthService.getExampleResponse()
.observeOn(mMainThread)
.subscribeOn(mNewThread)
.subscribe(new Observer<Example>() {
@Override
public void onSubscribe(Disposable d) {

}

@Override
public void onNext(Example example) {
Timber.d("example %s", example.toString());
}

@Override
public void onError(Throwable e) {
e.printStackTrace();
}

@Override
public void onComplete() {

}
});
}
}


here "userAuthService.getExampleResponse()" getting null. I think presenter need to know about RetrofitModule injection. So I need to fix this and how?










share|improve this question


























    up vote
    1
    down vote

    favorite












    Dagger2 learning is still difficult and am trying to learn. Have setup a project using new dagger android to avoid injecting inside activity class. So far it's working but need to use retrofit injected in presenter class. Added retrofit module in AppComponent but apiService class method getting null when call from presenter class. Need to know how to inject properly.



    AppComponent.java



    @Singleton
    @Component(modules = {
    /* Use AndroidInjectionModule.class if you're not using support library */
    AndroidSupportInjectionModule.class,
    AppModule.class,
    BuildersModule.class,
    RetrofitModule.class})
    public interface AppComponent {

    @Component.Builder
    interface Builder {
    @BindsInstance
    Builder application(BaseApplication application);

    Builder retrofitModule(RetrofitModule retrofitModule);

    AppComponent build();
    }

    void inject(BaseApplication app);
    }


    AppModule.java



    @Module
    class AppModule {

    @Provides
    Context provideContext(BaseApplication application) {
    return application.getApplicationContext();
    }
    }


    BuildersModule.java



    @Module
    public abstract class BuildersModule {

    @ContributesAndroidInjector(modules = {SplashViewModule.class, SplashModule.class})
    abstract SplashActivity bindSplashActivity();

    // Add bindings for other sub-components here
    }


    BaseApplication.java



    public class BaseApplication extends Application implements HasActivityInjector {

    @Inject
    DispatchingAndroidInjector<Activity> dispatchingAndroidInjector;

    @Override
    public void onCreate() {
    super.onCreate();

    //configure timber for logging
    if (BuildConfig.DEBUG) {
    Timber.plant(new Timber.DebugTree());
    }

    DaggerAppComponent
    .builder()
    .application(this)
    .retrofitModule(new RetrofitModule())
    .build()
    .inject(this);
    }


    @Override
    public AndroidInjector<Activity> activityInjector() {
    return dispatchingAndroidInjector;
    }
    }


    RetrofitModule.java



    @Module
    public class RetrofitModule {

    //get retrofit instance
    @Singleton
    @Provides
    public UserAuthService getRestService() {

    Gson gson = new GsonBuilder()
    .setLenient()
    .create();

    Retrofit retrofit = new Retrofit.Builder()
    .baseUrl(ApiConstants.BASE_URL)
    .addConverterFactory(GsonConverterFactory.create(gson))
    .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
    .client(getOkHttpClient())
    .build();

    return retrofit.create(UserAuthService.class);
    }
    }


    UserAuthService.java



    public interface UserAuthService {

    @GET("v2/5be345062f00006b00ca22c4")
    Observable<Example> getExampleResponse();
    }


    SplashModule.java



    @Module
    public class SplashModule {

    @Provides
    SplashPresenter provideSplashPresenter(SplashView splashView) {
    return new SplashPresenter(splashView);
    }
    }


    SplashViewModule.java



    @Module
    public abstract class SplashViewModule {

    @Binds
    abstract SplashView provideSplashView(SplashActivity splashActivity);

    }


    SplashPresenter.java



    class SplashPresenter extends BasePresenter<SplashView> {


    @Inject
    @Named(ValueConstants.MAIN_THREAD)
    Scheduler mMainThread;

    @Inject
    @Named(ValueConstants.NEW_THREAD)
    Scheduler mNewThread;

    @Inject
    UserAuthService userAuthService;

    SplashPresenter(SplashView view) {
    super(view);
    }

    //test purpose
    public void sayHello() {

    userAuthService.getExampleResponse()
    .observeOn(mMainThread)
    .subscribeOn(mNewThread)
    .subscribe(new Observer<Example>() {
    @Override
    public void onSubscribe(Disposable d) {

    }

    @Override
    public void onNext(Example example) {
    Timber.d("example %s", example.toString());
    }

    @Override
    public void onError(Throwable e) {
    e.printStackTrace();
    }

    @Override
    public void onComplete() {

    }
    });
    }
    }


    here "userAuthService.getExampleResponse()" getting null. I think presenter need to know about RetrofitModule injection. So I need to fix this and how?










    share|improve this question
























      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      Dagger2 learning is still difficult and am trying to learn. Have setup a project using new dagger android to avoid injecting inside activity class. So far it's working but need to use retrofit injected in presenter class. Added retrofit module in AppComponent but apiService class method getting null when call from presenter class. Need to know how to inject properly.



      AppComponent.java



      @Singleton
      @Component(modules = {
      /* Use AndroidInjectionModule.class if you're not using support library */
      AndroidSupportInjectionModule.class,
      AppModule.class,
      BuildersModule.class,
      RetrofitModule.class})
      public interface AppComponent {

      @Component.Builder
      interface Builder {
      @BindsInstance
      Builder application(BaseApplication application);

      Builder retrofitModule(RetrofitModule retrofitModule);

      AppComponent build();
      }

      void inject(BaseApplication app);
      }


      AppModule.java



      @Module
      class AppModule {

      @Provides
      Context provideContext(BaseApplication application) {
      return application.getApplicationContext();
      }
      }


      BuildersModule.java



      @Module
      public abstract class BuildersModule {

      @ContributesAndroidInjector(modules = {SplashViewModule.class, SplashModule.class})
      abstract SplashActivity bindSplashActivity();

      // Add bindings for other sub-components here
      }


      BaseApplication.java



      public class BaseApplication extends Application implements HasActivityInjector {

      @Inject
      DispatchingAndroidInjector<Activity> dispatchingAndroidInjector;

      @Override
      public void onCreate() {
      super.onCreate();

      //configure timber for logging
      if (BuildConfig.DEBUG) {
      Timber.plant(new Timber.DebugTree());
      }

      DaggerAppComponent
      .builder()
      .application(this)
      .retrofitModule(new RetrofitModule())
      .build()
      .inject(this);
      }


      @Override
      public AndroidInjector<Activity> activityInjector() {
      return dispatchingAndroidInjector;
      }
      }


      RetrofitModule.java



      @Module
      public class RetrofitModule {

      //get retrofit instance
      @Singleton
      @Provides
      public UserAuthService getRestService() {

      Gson gson = new GsonBuilder()
      .setLenient()
      .create();

      Retrofit retrofit = new Retrofit.Builder()
      .baseUrl(ApiConstants.BASE_URL)
      .addConverterFactory(GsonConverterFactory.create(gson))
      .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
      .client(getOkHttpClient())
      .build();

      return retrofit.create(UserAuthService.class);
      }
      }


      UserAuthService.java



      public interface UserAuthService {

      @GET("v2/5be345062f00006b00ca22c4")
      Observable<Example> getExampleResponse();
      }


      SplashModule.java



      @Module
      public class SplashModule {

      @Provides
      SplashPresenter provideSplashPresenter(SplashView splashView) {
      return new SplashPresenter(splashView);
      }
      }


      SplashViewModule.java



      @Module
      public abstract class SplashViewModule {

      @Binds
      abstract SplashView provideSplashView(SplashActivity splashActivity);

      }


      SplashPresenter.java



      class SplashPresenter extends BasePresenter<SplashView> {


      @Inject
      @Named(ValueConstants.MAIN_THREAD)
      Scheduler mMainThread;

      @Inject
      @Named(ValueConstants.NEW_THREAD)
      Scheduler mNewThread;

      @Inject
      UserAuthService userAuthService;

      SplashPresenter(SplashView view) {
      super(view);
      }

      //test purpose
      public void sayHello() {

      userAuthService.getExampleResponse()
      .observeOn(mMainThread)
      .subscribeOn(mNewThread)
      .subscribe(new Observer<Example>() {
      @Override
      public void onSubscribe(Disposable d) {

      }

      @Override
      public void onNext(Example example) {
      Timber.d("example %s", example.toString());
      }

      @Override
      public void onError(Throwable e) {
      e.printStackTrace();
      }

      @Override
      public void onComplete() {

      }
      });
      }
      }


      here "userAuthService.getExampleResponse()" getting null. I think presenter need to know about RetrofitModule injection. So I need to fix this and how?










      share|improve this question













      Dagger2 learning is still difficult and am trying to learn. Have setup a project using new dagger android to avoid injecting inside activity class. So far it's working but need to use retrofit injected in presenter class. Added retrofit module in AppComponent but apiService class method getting null when call from presenter class. Need to know how to inject properly.



      AppComponent.java



      @Singleton
      @Component(modules = {
      /* Use AndroidInjectionModule.class if you're not using support library */
      AndroidSupportInjectionModule.class,
      AppModule.class,
      BuildersModule.class,
      RetrofitModule.class})
      public interface AppComponent {

      @Component.Builder
      interface Builder {
      @BindsInstance
      Builder application(BaseApplication application);

      Builder retrofitModule(RetrofitModule retrofitModule);

      AppComponent build();
      }

      void inject(BaseApplication app);
      }


      AppModule.java



      @Module
      class AppModule {

      @Provides
      Context provideContext(BaseApplication application) {
      return application.getApplicationContext();
      }
      }


      BuildersModule.java



      @Module
      public abstract class BuildersModule {

      @ContributesAndroidInjector(modules = {SplashViewModule.class, SplashModule.class})
      abstract SplashActivity bindSplashActivity();

      // Add bindings for other sub-components here
      }


      BaseApplication.java



      public class BaseApplication extends Application implements HasActivityInjector {

      @Inject
      DispatchingAndroidInjector<Activity> dispatchingAndroidInjector;

      @Override
      public void onCreate() {
      super.onCreate();

      //configure timber for logging
      if (BuildConfig.DEBUG) {
      Timber.plant(new Timber.DebugTree());
      }

      DaggerAppComponent
      .builder()
      .application(this)
      .retrofitModule(new RetrofitModule())
      .build()
      .inject(this);
      }


      @Override
      public AndroidInjector<Activity> activityInjector() {
      return dispatchingAndroidInjector;
      }
      }


      RetrofitModule.java



      @Module
      public class RetrofitModule {

      //get retrofit instance
      @Singleton
      @Provides
      public UserAuthService getRestService() {

      Gson gson = new GsonBuilder()
      .setLenient()
      .create();

      Retrofit retrofit = new Retrofit.Builder()
      .baseUrl(ApiConstants.BASE_URL)
      .addConverterFactory(GsonConverterFactory.create(gson))
      .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
      .client(getOkHttpClient())
      .build();

      return retrofit.create(UserAuthService.class);
      }
      }


      UserAuthService.java



      public interface UserAuthService {

      @GET("v2/5be345062f00006b00ca22c4")
      Observable<Example> getExampleResponse();
      }


      SplashModule.java



      @Module
      public class SplashModule {

      @Provides
      SplashPresenter provideSplashPresenter(SplashView splashView) {
      return new SplashPresenter(splashView);
      }
      }


      SplashViewModule.java



      @Module
      public abstract class SplashViewModule {

      @Binds
      abstract SplashView provideSplashView(SplashActivity splashActivity);

      }


      SplashPresenter.java



      class SplashPresenter extends BasePresenter<SplashView> {


      @Inject
      @Named(ValueConstants.MAIN_THREAD)
      Scheduler mMainThread;

      @Inject
      @Named(ValueConstants.NEW_THREAD)
      Scheduler mNewThread;

      @Inject
      UserAuthService userAuthService;

      SplashPresenter(SplashView view) {
      super(view);
      }

      //test purpose
      public void sayHello() {

      userAuthService.getExampleResponse()
      .observeOn(mMainThread)
      .subscribeOn(mNewThread)
      .subscribe(new Observer<Example>() {
      @Override
      public void onSubscribe(Disposable d) {

      }

      @Override
      public void onNext(Example example) {
      Timber.d("example %s", example.toString());
      }

      @Override
      public void onError(Throwable e) {
      e.printStackTrace();
      }

      @Override
      public void onComplete() {

      }
      });
      }
      }


      here "userAuthService.getExampleResponse()" getting null. I think presenter need to know about RetrofitModule injection. So I need to fix this and how?







      java android dagger-2 dagger.android






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 8 at 11:02









      demo_Ashif

      13028




      13028
























          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote



          accepted










          I would add those dependencies to the constructor of SplashPresenter and add the @Inject annotation to it. Dagger2 supports constructor injection and all the dependencies you need are resolvable (and you can also get rid of SplashModule)



          class SplashPresenter extends BasePresenter<SplashView> {

          private Scheduler mMainThread;

          private Scheduler mNewThread;

          private UserAuthService userAuthService;

          @Inject
          SplashPresenter(SplashView view, UserAuthService userAuthService, @Named(ValueConstants.NEW_THREAD) Scheduler newThread, @Named(ValueConstants.MAIN_THREAD) Scheduler mainThread) {
          super(view);
          this.userAuthService = userAuthService;
          mNewThread = newThread;
          mMainThread = mainThread;
          }





          share|improve this answer























          • Thanks for your suggestion. Can you please add code snippet? (it may helpful to others too). And why u would like to get rid of SplashModule?
            – demo_Ashif
            Nov 8 at 11:36










          • I did add the snippet
            – Blackbelt
            Nov 8 at 11:42










          • Want to avoid constructor injection. Need to know proper way of injecting module in presenter class using component for dagger2 android.
            – demo_Ashif
            Nov 10 at 9:28










          • Constructor is the proper way with dagger 2.
            – Blackbelt
            Nov 10 at 9:37











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














           

          draft saved


          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53206400%2fdagger2-how-to-inject-retrofit-module-in-presenter-class%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          0
          down vote



          accepted










          I would add those dependencies to the constructor of SplashPresenter and add the @Inject annotation to it. Dagger2 supports constructor injection and all the dependencies you need are resolvable (and you can also get rid of SplashModule)



          class SplashPresenter extends BasePresenter<SplashView> {

          private Scheduler mMainThread;

          private Scheduler mNewThread;

          private UserAuthService userAuthService;

          @Inject
          SplashPresenter(SplashView view, UserAuthService userAuthService, @Named(ValueConstants.NEW_THREAD) Scheduler newThread, @Named(ValueConstants.MAIN_THREAD) Scheduler mainThread) {
          super(view);
          this.userAuthService = userAuthService;
          mNewThread = newThread;
          mMainThread = mainThread;
          }





          share|improve this answer























          • Thanks for your suggestion. Can you please add code snippet? (it may helpful to others too). And why u would like to get rid of SplashModule?
            – demo_Ashif
            Nov 8 at 11:36










          • I did add the snippet
            – Blackbelt
            Nov 8 at 11:42










          • Want to avoid constructor injection. Need to know proper way of injecting module in presenter class using component for dagger2 android.
            – demo_Ashif
            Nov 10 at 9:28










          • Constructor is the proper way with dagger 2.
            – Blackbelt
            Nov 10 at 9:37















          up vote
          0
          down vote



          accepted










          I would add those dependencies to the constructor of SplashPresenter and add the @Inject annotation to it. Dagger2 supports constructor injection and all the dependencies you need are resolvable (and you can also get rid of SplashModule)



          class SplashPresenter extends BasePresenter<SplashView> {

          private Scheduler mMainThread;

          private Scheduler mNewThread;

          private UserAuthService userAuthService;

          @Inject
          SplashPresenter(SplashView view, UserAuthService userAuthService, @Named(ValueConstants.NEW_THREAD) Scheduler newThread, @Named(ValueConstants.MAIN_THREAD) Scheduler mainThread) {
          super(view);
          this.userAuthService = userAuthService;
          mNewThread = newThread;
          mMainThread = mainThread;
          }





          share|improve this answer























          • Thanks for your suggestion. Can you please add code snippet? (it may helpful to others too). And why u would like to get rid of SplashModule?
            – demo_Ashif
            Nov 8 at 11:36










          • I did add the snippet
            – Blackbelt
            Nov 8 at 11:42










          • Want to avoid constructor injection. Need to know proper way of injecting module in presenter class using component for dagger2 android.
            – demo_Ashif
            Nov 10 at 9:28










          • Constructor is the proper way with dagger 2.
            – Blackbelt
            Nov 10 at 9:37













          up vote
          0
          down vote



          accepted







          up vote
          0
          down vote



          accepted






          I would add those dependencies to the constructor of SplashPresenter and add the @Inject annotation to it. Dagger2 supports constructor injection and all the dependencies you need are resolvable (and you can also get rid of SplashModule)



          class SplashPresenter extends BasePresenter<SplashView> {

          private Scheduler mMainThread;

          private Scheduler mNewThread;

          private UserAuthService userAuthService;

          @Inject
          SplashPresenter(SplashView view, UserAuthService userAuthService, @Named(ValueConstants.NEW_THREAD) Scheduler newThread, @Named(ValueConstants.MAIN_THREAD) Scheduler mainThread) {
          super(view);
          this.userAuthService = userAuthService;
          mNewThread = newThread;
          mMainThread = mainThread;
          }





          share|improve this answer














          I would add those dependencies to the constructor of SplashPresenter and add the @Inject annotation to it. Dagger2 supports constructor injection and all the dependencies you need are resolvable (and you can also get rid of SplashModule)



          class SplashPresenter extends BasePresenter<SplashView> {

          private Scheduler mMainThread;

          private Scheduler mNewThread;

          private UserAuthService userAuthService;

          @Inject
          SplashPresenter(SplashView view, UserAuthService userAuthService, @Named(ValueConstants.NEW_THREAD) Scheduler newThread, @Named(ValueConstants.MAIN_THREAD) Scheduler mainThread) {
          super(view);
          this.userAuthService = userAuthService;
          mNewThread = newThread;
          mMainThread = mainThread;
          }






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 8 at 11:42

























          answered Nov 8 at 11:07









          Blackbelt

          127k22208236




          127k22208236












          • Thanks for your suggestion. Can you please add code snippet? (it may helpful to others too). And why u would like to get rid of SplashModule?
            – demo_Ashif
            Nov 8 at 11:36










          • I did add the snippet
            – Blackbelt
            Nov 8 at 11:42










          • Want to avoid constructor injection. Need to know proper way of injecting module in presenter class using component for dagger2 android.
            – demo_Ashif
            Nov 10 at 9:28










          • Constructor is the proper way with dagger 2.
            – Blackbelt
            Nov 10 at 9:37


















          • Thanks for your suggestion. Can you please add code snippet? (it may helpful to others too). And why u would like to get rid of SplashModule?
            – demo_Ashif
            Nov 8 at 11:36










          • I did add the snippet
            – Blackbelt
            Nov 8 at 11:42










          • Want to avoid constructor injection. Need to know proper way of injecting module in presenter class using component for dagger2 android.
            – demo_Ashif
            Nov 10 at 9:28










          • Constructor is the proper way with dagger 2.
            – Blackbelt
            Nov 10 at 9:37
















          Thanks for your suggestion. Can you please add code snippet? (it may helpful to others too). And why u would like to get rid of SplashModule?
          – demo_Ashif
          Nov 8 at 11:36




          Thanks for your suggestion. Can you please add code snippet? (it may helpful to others too). And why u would like to get rid of SplashModule?
          – demo_Ashif
          Nov 8 at 11:36












          I did add the snippet
          – Blackbelt
          Nov 8 at 11:42




          I did add the snippet
          – Blackbelt
          Nov 8 at 11:42












          Want to avoid constructor injection. Need to know proper way of injecting module in presenter class using component for dagger2 android.
          – demo_Ashif
          Nov 10 at 9:28




          Want to avoid constructor injection. Need to know proper way of injecting module in presenter class using component for dagger2 android.
          – demo_Ashif
          Nov 10 at 9:28












          Constructor is the proper way with dagger 2.
          – Blackbelt
          Nov 10 at 9:37




          Constructor is the proper way with dagger 2.
          – Blackbelt
          Nov 10 at 9:37


















           

          draft saved


          draft discarded



















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53206400%2fdagger2-how-to-inject-retrofit-module-in-presenter-class%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Schultheiß

          Liste der Kulturdenkmale in Wilsdruff

          Android Play Services Check