lpirro
12/18/2022, 6:19 PMdomain
module, and the implementation in the repository
module with the repository
module depending on the domain
one) but receiving an error when building the app:
DomainModule.kt - lives into :domain
module
@Module
@InstallIn(SingletonComponent::class)
object DomainModule {
@Provides
fun provideGetUpcomingLaunchesUseCase(repository: SpaceHubRepository): GetUpcomingLaunchesUseCase {
return GetUpcomingLaunchesUseCaseImpl(repository)
}
}
SpaceHubRepository.kt - lives into: :domain
module
interface SpaceHubRepository {
suspend fun getUpcomingLaunches(): Flow<List<Launch>>
}
RepositoryModule.kt - lives into :repository
module
@Module
@InstallIn(SingletonComponent::class)
object RepositoryModule {
@Provides
fun provideRepository(
apiService: SpaceHubApiService,
launchMapper: LaunchMapper
): SpaceHubRepository {
return SpaceHubRepositoryImpl(apiService, launchMapper)
}
@Provides
fun provideLaunchMapper(): LaunchMapper = LaunchMapperImpl()
}
lpirro
12/18/2022, 6:20 PM/Users/lpirro/AndroidStudioProjects/SpaceHub/app/build/generated/hilt/component_sources/debug/com/lpirro/spacehub/SpaceHubApp_HiltComponents.java:128: error: [Dagger/MissingBinding] com.lpirro.domain.repository.SpaceHubRepository cannot be provided without an @Provides-annotated method.
public abstract static class SingletonC implements SpaceHubApp_GeneratedInjector,
^
com.lpirro.domain.repository.SpaceHubRepository is injected at
com.lpirro.domain.di.DomainModule.provideGetUpcomingLaunchesUseCase(repository)
com.lpirro.domain.usecase.GetUpcomingLaunchesUseCase is injected at
com.lpirro.launches.upcoming.viewmodel.UpcomingLaunchesViewModel(useCase)
com.lpirro.launches.upcoming.viewmodel.UpcomingLaunchesViewModel is injected at
com.lpirro.launches.upcoming.viewmodel.UpcomingLaunchesViewModel_HiltModules.BindsModule.binds(arg0)
@dagger.hilt.android.internal.lifecycle.HiltViewModelMap java.util.Map<java.lang.String,javax.inject.Provider<androidx.lifecycle.ViewModel>> is requested at
dagger.hilt.android.internal.lifecycle.HiltViewModelFactory.ViewModelFactoriesEntryPoint.getHiltViewModelMap() [com.lpirro.spacehub.SpaceHubApp_HiltComponents.SingletonC → com.lpirro.spacehub.SpaceHubApp_HiltComponents.ActivityRetainedC → com.lpirro.spacehub.SpaceHubApp_HiltComponents.ViewModelC]
Chrimaeon
12/18/2022, 6:36 PMYves Kalume
12/18/2022, 7:33 PMlpirro
12/18/2022, 7:45 PMapi project(':repository')
to my :app
module and now it’s working.
But in terms of clean arch, feels a bit wrong to me that the app module has a dependency on the repository module, isn’t it?Yves Kalume
12/18/2022, 8:09 PMlpirro
12/18/2022, 8:09 PM