Dagger: IllegalArgumentException: No injector factory bound for Class

I believe you have forgot to put @ContributesAndroidInjector annotation:


    @Module
    public abstract class ActivityModule {
        @ContributesAndroidInjector
        abstract ProductListActivity contributeProductListActivity();
        @ContributesAndroidInjector
        abstract ProductDetailsActivity contributeProductDetailsActivity();
    }

And include ViewModelModule within AppModule:


    @Module(includes = ViewModelModule.class)
    class AppModule {
        ...
    }


See this code that you have wrote:

@Provides
@Singleton
ProductListRepository provideProductListRepository(ProductListRepository repository) {
    return repository;
}

What do you expect to happen? You are telling dagger “hey, dagger, whenever I ask you to provide me ProductListRepository then create(return) that object using ProductListRepository. That’s not gonna work out.

Most possibly what you intended was “hey, dagger, whenever I ask you to provide me an implementation of ProductListRepository then create(return) that object using ProductListRepositoryImpl:

@Provides
@Singleton
ProductListRepository provideProductListRepository(ProductListRepositoryImpl repository) {
    return repository;
}

Which may be substituted with following:

@Binds
@Singleton
abstract ProductListRepository provideProductListRepository(ProductListRepositoryImpl repository);

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)