I have this component:
@Singleton
@Component(modules = OauthModule.class)
public interface OauthComponent {
void inject(LoginActivity a);
}
and the module:
@Module
public class OauthModule {
@Provides
@Singleton
Oauth2Service provideOauth2Service() {
return new Oauth2StaticService();
}
}
and this another component:
@Singleton
@Component(modules = LoggedUserModule.class)
public interface LoggedUserComponent {
void inject(LoginActivity a);
}
and I get this error:
Error:(15, 10) error: Oauth2Service cannot be provided without an @Provides- or @Produces-annotated method.
If I change the LoggedUserComponent
's inject method parameter to be another Activity
, say AnotherActivity
like this:
@Singleton
@Component(modules = LoggedUserModule.class)
public interface LoggedUserComponent {
void inject(AnotherActivity a);
}
compilation is ok. Why? Can't I have two components with the same inject signature?
I'm trying to understand how Dagger
works so any help will be appreciated. Thanks.