I have following module with @Provides method with a qualifier
@Module
class VocabularyModule {
@VocabularyProviders
@Singleton
@Provides
fun provideVocabularies(): List<VocabularyProvider> {
return listOf(
AnimalsVocabularyProvider(),
FamilyVocabularyProvider(),
FoodVocabularyProvider(),
NumberVocabularyProvider(),
ColorsVocabularyProvider(),
FreeTimeVocabularyProvider(),
SportVocabularyProvider(),
NatureVocabularyProvider(),
PeopleVocabularyProvider(),
TransportationVocabularyProvider()
)
}
}
@Qualifier
@Retention(AnnotationRetention.RUNTIME)
annotation class VocabularyProviders
Then there is my class that I want to inject this list into via constructor and the qualifier:
class VocabularyFactory
@Inject constructor(@param:VocabularyProviders val providers: List<VocabularyProvider>) {
fun getVocabulary(category: VocabularyCategory): Vocabulary {
for (provider in providers) {
if (category == provider.category) {
return provider.vocabulary
}
}
throw IllegalStateException("didn't find provider that could provide vocabulary of $category category")
}
}
I am getting this error but everything looks correct
11: error: [Dagger/MissingBinding] [dagger.android.AndroidInjector.inject(T)] @cz.ejstn.learnlanguageapp.core.dagger.module.vocabulary.VocabularyProviders java.util.List<? extends cz.ejstn.learnlanguageapp.vocabulary.model.factory.VocabularyProvider> cannot be provided without an @Provides-annotated method.