The error I have is following:
Caused by: java.lang.IllegalArgumentException: No injector factory bound for Class. Injector factories were bound for supertypes of MyActivity_: [MyActivity]. Did you mean to bind an injector factory for the subtype?
As I understand it happens because I am using an AndroidAnnotations library.
AppComponent.class :
@Singleton
@Component(modules = {
AndroidInjectionModule.class,
AppModule.class,
ActivityBindingModule.class })
public interface AppComponent extends AndroidInjector<DaggerApplication> {
@Component.Builder
interface Builder {
@BindsInstance Builder application(Application application);
AppComponent build();
}
void inject(Application application);
@Override
void inject(DaggerApplication instance);
}
AppModule.class :
@Module
public abstract class AppModule {
@Binds
abstract Context provideContext(Application application);
@Provides
@Singleton
static SharedPreferencesManager providesPreferences(Application application){
return SharedPreferencesManager_.getInstance_(application);
}
}
ActivityBindingModule.class :
@Module
public abstract class ActivityBindingModule {
@ContributesAndroidInjector(modules = LoginActivityModule.class)
@LoginActivityScope
abstract LoginActivity bindLoginActivity();
}
Application.class :
@EApplication
public class Application extends DaggerApplication {
@Inject
DispatchingAndroidInjector<Activity> activityDispatchingAndroidInjector;
protected AndroidInjector<? extends DaggerApplication> applicationInjector() {
AppComponent appComponent = DaggerAppComponent.builder()
.application(this)
.build();
appComponent.inject(this);
return appComponent;
}
}
LoginActivityModule.class
@Module
public class LoginActivityModule {
@Provides
@LoginActivityScope
@ActivityContext
public Context providesContext(LoginActivity loginActivity){
return loginActivity;
}
@Provides
@LoginActivityScope
public LoginViewModel providesLoginViewModel(TelephonyManager telephonyManager,
LoginModel loginModel,
SharedPreferencesManager sharedPreferencesManager,
LoginRemoteRepository loginRemoteRepository){
return new LoginViewModel(telephonyManager, loginModel, sharedPreferencesManager, loginRemoteRepository,
new CompositeSubscription());
}
@Provides
@LoginActivityScope
public LoginRemoteRepository providesRemoteRepository(@ActivityContext Context context,
MainApi mainApi,
SharedPreferencesManager sharedPreferencesManager){
return new LoginRemoteRepository(mainApi, sharedPreferencesManager, context.getContentResolver());
}
@Provides
@LoginActivityScope
public LoginModel provideLoginModel(){
return new LoginModel();
}
@Provides
@LoginActivityScope
public TelephonyManager provideTelephonyManager(Context context){
return (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
}
}
LoginActivity.class :
@EActivity(R.layout.activity_login)
public class LoginActivity {
@Inject
LoginViewModel loginViewModel;
@AfterViews
void afterViews(){
AndroidInjection.inject(this);
}
}