Reputation: 558
I'm facing an issue while trying to use Dagger's subcomponent. When I try to build this I get this error.
@Subcomponent.Builder setter methods must return void, the builder, or a supertype of the builder. Inherited method: create(T).
Does anyone have any idea what I'm doing wrong here?
Thanks.
@FragmentScope
@Subcomponent(modules = [OnBoardingWelcomeFragmentModule::class])
interface OnBoardingWelcomeFragmentComponent: AndroidInjector<OnBoardingWelcomeFragment> {
@Subcomponent.Builder
interface Builder: AndroidInjector.Factory<OnBoardingWelcomeFragment>
}
@Module
open class OnBoardingWelcomeFragmentModule {
@Provides
@FragmentScope
fun provideUI() = OnBoardingWelcomeFragmentUi()
@Provides
@ViewModelForDagger
fun providesViewModelForDagger(sharedPrefsStorage: SharedPrefsStorage): OnboardingViewModel =
OnboardingViewModel(sharedPrefsStorage)
@Provides
fun providesViewModelFactory(@ViewModelForDagger
viewModel: Lazy<OnboardingViewModel>): ViewModelFactory<OnboardingViewModel> =
ViewModelFactory(viewModel)
}
Upvotes: 0
Views: 130
Reputation: 34532
You should switch AndroidInjector.Factory
to AndroidInjector.Builder
instead which implements AndroidInjector.Factory
.
abstract class Builder: AndroidInjector.Builder<OnBoardingWelcomeFragment>
The Factory
interface adds a method for dagger.android
to use which you would have to implement yourself, since Dagger doesn't know how to—hence the error.
Upvotes: 2