I have a Component
to provide dependencies for Data Input:
@Component(modules = [DataInputModule::class])
interface DataInputComponent {
fun inject(activity: DataInputActivity)
fun factory(): Factory
@Component.Factory
interface Factory {
fun create(@BindsInstance activity: DataInputActivity, module: DataInputModule): DataInputComponent
}
}
With the module:
@Module
class DataInputModule(private val activity: DataInputActivity) {
@Provides
fun provideDataInputViewModel(repo: MyRepository, timestampProvider: TimestampProvider) =
DefaultDataInputViewModel(repo, timestampProvider)
@Provides
fun provideTimestampProvider(): TimestampProvider = DefaultTimestampProvider()
@Provides
fun provideDateTimeDialogFactory(): DateTimeDialogFactory = DateTimeDialogFactory(activity)
}
My application's component looks like so:
@Singleton
@Component(
modules = [
DataListModule::class
]
)
interface AppComponent : AndroidInjector<MyApplication> {
@Component.Factory
interface Factory {
fun create(@BindsInstance app: MyApplication): AppComponent
}
}
with the module to provide the trusty Room database and the repository.
When trying to build I get the following error:
D:\Applications\AndroidStudioProjects\MyApp\app\build\tmp\kapt3\stubs\debug\com\example\myapp\di\component\DataInputComponent.java:7: error: [Dagger/MissingBinding] com.example.myapp.di.component.DataInputComponent.Factory cannot be provided without an @Provides-annotated method. public abstract interface DataInputComponent { ^ com.example.myapp.di.component.DataInputComponent.Factory is provided at com.example.myapp.di.component.DataInputComponent.factory()
I cannot add a @Provides
to the @Component
because it is not a module. I looked for docs online but found no example of anyone "provides" annotating and providing a @Factory
. So what could cause the issue here?