Java Dagger:在具有多次注入的类上没有可注入成员

Java Dagger:在具有多次注入的类上没有可注入成员,java,android,dependency-injection,code-injection,dagger,Java,Android,Dependency Injection,Code Injection,Dagger,尝试将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

尝试将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
我无法理解此错误消息,因为这两个模块之间似乎没有任何关系。在我添加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;
}
}
@Module(injects = {AuthenticatorActivity.class})
public class ServerHandlerModule {

public ServerHandlerModule() {}

@Provides
@Singleton
ServerHandler providesServerHandler() {
    return new ServerHandler();
}
ServerHandlerModule:

@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;
}
}
@Module(injects = {AuthenticatorActivity.class})
public class ServerHandlerModule {

public ServerHandlerModule() {}

@Provides
@Singleton
ServerHandler providesServerHandler() {
    return new ServerHandler();
}
}

验证器活动:

public class AuthenticatorActivity extends AccountAuthenticatorActivity {
@Inject
SQLiteHandler db;
@Inject
ServerHandler serverHandler;

private ObjectGraph objectGraph;


@Override
protected void onCreate(Bundle savedInstanceState) {
    objectGraph = ObjectGraph.create(getModules());
    objectGraph.inject(this);
}

…

protected List<Object> getModules() {
    return Arrays.asList(new SQLiteHandlerModule(this), new ServerHandlerModule());
}
}
公共类AuthenticatorActivity扩展AccountAuthenticatorActivity{
@注入
SQLiteHandler数据库;
@注入
服务器处理程序服务器处理程序;
私有对象图对象图;
@凌驾
创建时受保护的void(Bundle savedInstanceState){
objectGraph=objectGraph.create(getModules());
objectGraph.inject(this);
}
…
受保护的列表getModules(){
返回Arrays.asList(新的SQLiteHandlerModule(this),新的ServerHandlerModule());
}
}

有人知道我需要添加什么来解决这个问题吗?

Dagger需要对要注入的类的构造函数进行注释

@Inject
public SQLiteHandler(@ForApplication Context context) {
    super(context, DATABASE_NAME, null, DATABASE_VERSION);
    this.context = context;
}

@Inject
public ServerHandler() {
}

Dagger需要对要注入的类的构造函数进行注释

@Inject
public SQLiteHandler(@ForApplication Context context) {
    super(context, DATABASE_NAME, null, DATABASE_VERSION);
    this.context = context;
}

@Inject
public ServerHandler() {
}