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問題?