I have an Android app that uses Dagger. There are certain sections of the entire app that I want to add scoped ObjectGraphs for several activities that share a common scope. The following module is in the root ObjectGraph
@Module(
injects = {
MyApplication.class,
},
complete = false,
library = true)
public class BasicContextManagerModule {
private Context applicationContext;
public BasicContextManagerModule(Context applicationContext) {
this.applicationContext = applicationContext;
}
@Provides
Context getApplicationContext() {
return applicationContext;
}
}
Then I try to add the following Module through existingObjectGraph.plus(new FileManagerModule());
@Module(
injects = {
MyListActivity.class,
MyFileDetailActivity.class,
MyFileInfoActivity.class,
},
includes = BasicContextManagerModule.class
)
public class FileManagerModule {
@Provides
FileManager provideFileManager(Context context) {
return new FileManager(context);
}
}
But the result is
java.lang.UnsupportedOperationException: No no-args constructor com.myapp.core.modules.BasicContextManagerModule$$ModuleAdapter
Can someone help me understand why the plus won't allow this? I read from the dagger documentation that plus extends the object graph and you can have includes and addsTo Modules. But I haven't been able to achieve this.