Dagger 2 – 为什么这是一个依赖循环?

我正在尝试将应用程序的Context注入其他两个对象,即AuthManagerApiClient

它们都取决于所述上下文, ApiClient依赖于AuthManager 。 为什么这是一个依赖循环,如果Context没有引用其他2? 这可以解决吗?

编辑:这是一些代码

 @Module public class AppModule { private final Application application; public AppModule(Application application) { this.application = application; } @Provides @Singleton Context provideApplicationContext() { return this.application; } } @Module public class NetworkModule { @Provides @Singleton public AuthManager providesAuthManager(AuthManager manager) { return manager; } @Provides @Singleton public ApiClient providesApiClient(ApiClientFactory factory) { return factory.create(); } } @Singleton @Component(modules = {AppModule.class, NetworkModule.class}) public interface ApplicationComponent { void inject(BaseActivity activity); // Exported for child-components Context context(); ApiClient apiClient(); AuthManager authManager(); } 

 @Provides @Singleton public AuthManager providesAuthManager(AuthManager manager) { return manager; } 

providesAuthManager AuthManager方法取决于AuthManager

这是你的周期:)

删除@Inject方法并在AuthManager构造函数中添加@Inject