Trying to use dagger to create a single instance of my database helper so I can access it easier from the various fragments in my app. Everytime I launch the app though it closes with the following error:
Caused by: java.lang.IllegalStateException: Errors creating object graph:
android.content.Context has no injectable members. Do you want to add an injectable constructor? required by class com.dring.smartcut.Modules.myModule
Here is my Module:
@Module(
complete = false,
injects = {
BaseApplication.class,
MainActivity.class,
MainFragment.class,
}
)
public class myModule {
private Context appContext;
public myModule(Context context) {
this.appContext = context;
}
@Provides @Singleton Bus provideBus(){
return new Bus();
}
@Provides @Singleton
RecipeReaderHelper provideRecipeReaderHelper(Context context){
return new RecipeReaderHelper(context);
}
}
And the ObjectGraph Creation:
objectGraph = ObjectGraph.create(new myModule(this));
objectGraph.inject(this);
Any Help would be appreciated
Aucun commentaire:
Enregistrer un commentaire