匕首2。如果没有 @Provides 注释的方法,我的 @Module 对象就无法提供

Dagger2. My @Module Object cannot be provided without an @Provides-annotated method

但实际上是这样。我搜索了其他问题以解决此问题,但没有人解决我的问题。错误状态

network.Repository cannot be provided without an @Provides-annotated method. network.Repository is injected at module.LoginModule.provideLoginPresenter(repository)

我用

apt 'com.google.dagger:dagger-compiler:2.5' 
compile 'com.google.dagger:dagger:2.5'

我的代码

ApplicationComponent

@PerApplication
@Component(modules = {ApplicationModule.class, RestModule.class, WebSocketModule.class})
public interface ApplicationComponent {

    MyApplication myApplication();
    @PerApplication Repository repository(Retrofit retrofit); // testet without arg in constructor as well
    WebSocket webSocket();
}

登录组件

@PerLogin
@Component(dependencies = {ApplicationModule.class},
        modules = {LoginModule.class})
public interface LoginComponent {

    void inject(LoginView loginView);

    LoginPresenter getLoginPresenter();

}

休息模块

    @Module
    public class RestModule {


        @Provides
        @PerApplication
        Repository provideRepository(Retrofit retrofit){
            return new RetrofitRestRepository(retrofit);
        }

 [...]
        @Provides
        @PerApplication
        Retrofit provideRetrofit(...){
             [...]
            return retrofit;
        }
    }

登录模块

@Module
public class LoginModule {

    @Provides
    @PerLogin
    public LoginPresenter provideLoginPresenter(Repository repository){
        return new LoginPresenter(repository);
    }
}

应该是

dependencies = {ApplicationComponent.class},

而不是

dependencies = {ApplicationModule.class},

而 ApplicationComponent 应该有

 Repository repository();

而不是

 @PerApplication Repository repository(Retrofit retrofit); // testet without arg in constructor as well