Im trying to add some dependency injection in my android project, so following example what i found i created my module
@Module(entryPoints = {MyActivity.class})
public class MyModule {
private final Context context;
public MyModule (Context context) {
this.context = context.getApplicationContext();
}
@Provides
@Singleton
Context applicationContext() {
return context;
}
@Provides
@Singleton
EventBus provideEventBus() {
return EventBusFactory.create();
}
}
i have my application:
public class MyApplication extends Application{
private ObjectGraph objectGraph;
@Override
public void onCreate() {
super.onCreate();
objectGraph = ObjectGraph.get(new MyModule(this));
}
public ObjectGraph getObjectGraph() {
return objectGraph;
}
}
and activity
public class MyActivity extends Activity {
@App
MyApplication application;
@Inject
EventBus eventBus;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ObjectGraph objectGraph = application.getObjectGraph();
objectGraph.inject(this);
....
i'm not sure what i'm doing wrong or what i missed, but my eclipse shows me error:
The method get(Class) in the type ObjectGraph is not applicable for the arguments (MyModuleModule)
in this line objectGraph = ObjectGraph.get(new MyModule(this));
and when i'm trying to do build i get:
No binding for my.android.lib.EventBus required by my.android.app.MyActivity for my.android.app.MyModule
is anyone can tell me what i'm doing wrong and what i forgot about?