This is MVP Module
@PosterFragmentScope
@Module
public class PosterFragmentModule {
PosterFragmentMVP.View view;
Context mContext;
public PosterFragmentModule(PosterFragmentMVP.View view,Context mContext) {
this.view = view;
this.mContext = mContext;
}
@PosterFragmentScope
@Provides
public PosterFragmentPresenter providePresenter(PosterFragmentMVP.View view , PosterFragmentMVP.InterActor interActor){
return new PosterFragmentPresenter(view,interActor,mContext);
}
@PosterFragmentScope
@Provides
public PosterFragmentMVP.View provideView(){
return view;
}
@PosterFragmentScope
@Provides
public PosterFragmentInteractor provideInteractor(APIServices.TMDbPopular tmDbPopular,APIServices.TMDbServiceTopRated tmDbServiceTopRated){
return new PosterFragmentInteractor(tmDbPopular,tmDbServiceTopRated);
}
@PosterFragmentScope
@Provides
public PosterFragmentMVP.Presenter providePresenterInterface(APIServices.TMDbPopular tmDbPopular,APIServices.TMDbServiceTopRated tmDbServiceTopRated){
return providePresenter(view,provideInteractor(tmDbPopular,tmDbServiceTopRated));
}
@Provides
@PosterFragmentScope
Context provideContext() {
return mContext;
}
@Provides
@PosterFragmentScope
public PosterAdapter provideAdapter(){
return new PosterAdapter(mContext,new ArrayList<Movie>());
}
@Provides
@PosterFragmentScope
public APIServices.TMDbPopular provideTmDbPopular(Retrofit retrofit){
return retrofit.create(APIServices.TMDbPopular.class);
}
@Provides
@PosterFragmentScope
public APIServices.TMDbServiceTopRated provideTmDbServiceTopRated(Retrofit retrofit){
return retrofit.create(APIServices.TMDbServiceTopRated.class);
}
}
This API Module
@Module
@Singleton
public class APIModule {
private final String BASEURL = "https://api.themoviedb.org/";
@Provides
@Singleton
public OkHttpClient provideClinet (){
HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
return new OkHttpClient.Builder().addInterceptor(interceptor).build();
}
@Provides
@Singleton
public Retrofit provideRetrofit(String base_url, OkHttpClient okHttpClient){
return new Retrofit.Builder()
.baseUrl(base_url)
.client(okHttpClient)
.addConverterFactory(GsonConverterFactory.create())
.build();
}
@Provides
public APIServices.TrailersService provideTrailersService() {
return provideRetrofit(BASEURL, provideClinet()).create(APIServices.TrailersService.class);
}
@Provides
public APIServices.ReviewsService provideReviewsService() {
return provideRetrofit(BASEURL, provideClinet()).create(APIServices.ReviewsService.class);
}
This Is APP Component
@Component(modules = {RoomModule.class,APIModule.class})
@Singleton
public interface APPComponent {
PosterFragmentComponent plus(PosterFragmentModule posterFragmentModule);
MovieDetailComponent plus(MovieDetailFragmentModule movieDetailFragmentModule);
}
This Is poster Component
@Subcomponent(modules =PosterFragmentModule.class)
@PosterFragmentScope
public interface PosterFragmentComponent {
void inject(PosterFragment posterFragment);
}
When i make this give me that error
Error:(19, 8) error: [com.example.ali.moviedb.DI.Components.PosterFragmentComponent.inject(com.example.ali.moviedb.Views.PosterFragment)] java.lang.String cannot be provided without an @Inject constructor or from an @Provides-annotated method. java.lang.String is injected at com.example.ali.moviedb.DI.Modules.APIModule.provideRetrofit(base_url, …) retrofit2.Retrofit is injected at com.example.ali.moviedb.DI.Modules.PosterFragmentModule.provideTmDbPopular(retrofit) com.example.ali.moviedb.Contracts.APIServices.TMDbPopular is injected at com.example.ali.moviedb.DI.Modules.PosterFragmentModule.providePresenterInterface(tmDbPopular, …) com.example.ali.moviedb.Contracts.PosterFragmentMVP.Presenter is injected at com.example.ali.moviedb.Views.PosterFragment.presenter com.example.ali.moviedb.Views.PosterFragment is injected at com.example.ali.moviedb.DI.Components.PosterFragmentComponent.inject(posterFragment)