Category : dagger-2

I am learning to use dager and at first I do not see the failure of this error AppComponent.java:8: error: [Dagger/MissingBinding] com.example.demo.domain.usecase.LoginUseCase cannot be provided without an @Inject constructor or an @Provides-annotated method. public abstract interface AppComponent { ^ com.example.demo.domain.usecase.LoginUseCase is injected at com.example.demo.di.module.ActivityModule.provideAuthPresenter(?, loginUseCase) com.example.demo.presentation.presenter.AuthPresenter is injected at com.example.demo.presentation.view.activity.AuthActivity.presenter com.example.demo.presentation.view.activity.AuthActivity is injected at com.example.demo.di.component.ActivityComponent.inject(com.example.demo.presentation.view.activity.AuthActivity) ..

Read more

I’m using Dagger for DI and Retrofit for network. When i trying to call retrofits api method in my presenter, i catchs NPE. Here is Network module: @Module public class NetworkModule { String baseUrl; public NetworkModule(String baseUrl) { this.baseUrl = baseUrl; } @Provides @Singleton Gson provideGson() { GsonBuilder gsonBuilder = new GsonBuilder(); return gsonBuilder.create(); } ..

Read more

I have a library module that contains an activity whose dependencies are provided with dagger. Now, I want to create some android tests in my library module. I need to replace some dagger modules with test modules, so I need to create extend my AppComponent and create a TestComponent that provides the test dependencies. But ..

Read more

Im working on trying to provide my API service into a FragmentModule but its not working the way I have setup my Dependency injection, Im receiving a MissingBiding Error even though I have include the corresponding modules into the FragmentModule. This is my setup: AppModule @Module @InstallIn(value = [SingletonComponent::class]) object AppModule { @Provides fun provideApplication(application: ..

Read more

I’m injecting with Dagger-Hilt a class with a dependency on @ActivityContext in a ViewModel, this module is installed in ActivityComponent and scoped to activity and it’s throwing me an error whenever I try to compile. For your information I have other modules with ActivityRetainedComponent and SingletonComponent injecting @ApplicationContext. Now I’m trying to figure out what ..

Read more