1
我正在试图注入2个模块到一个类时的错误消息:匕首:上类没有注射的成员多次注射
Error:(18, 8) error: No injectable members on ...SQLiteHandler.
Do you want to add an injectable constructor? required by ...activity.AuthenticatorActivity
for ...ServerHandlerModule
Error:(18, 8) error: No injectable members on ...ServerHandler.
Do you want to add an injectable constructor? required by ....activity.AuthenticatorActivity
for ...Modules.SQLiteHandlerModule
我无法理解此错误消息作为两个模块别t似乎彼此有任何关系。在我添加ServerHandlerModule之前,注入工作正常,但当它们都被注入时,它们似乎互相干扰。
SQLiteHandlerModule:
@Module(injects = {AuthenticatorActivity.class, MainActivity.class})
public class SQLiteHandlerModule {
private final Context context;
public SQLiteHandlerModule(Context context) {
this.context = context;
}
@Provides
@Singleton
SQLiteHandler providesSQLiteHandler(@ForApplication Context context) {
return new SQLiteHandler(context);
}
@Provides
@Singleton
@ForApplication
Context provideApplicationContext() {
return context;
}
}
ServerHandlerModule:
@Module(injects = {AuthenticatorActivity.class})
public class ServerHandlerModule {
public ServerHandlerModule() {}
@Provides
@Singleton
ServerHandler providesServerHandler() {
return new ServerHandler();
}
}
AuthenticatorActivity:
有谁知道我需要添加到解决THI问题?