According to your comment, you want to make NetworkingManager available throughout the application.
Let's start with the definition of Component :
@Singleton @Component(modules = AppModule.class) public interface AppComponent { void inject(App application); }
This tells the Dagger that this component will introduce the App class. Now you can also tell other daggers that you would like to add. Therefore, if you want to also enter Activity , for example, you would add:
@Singleton @Component(modules = AppModule.class) public interface AppComponent { void inject(App application); void inject(MainActivity activity)
Please note that this is not the best way, IMO, for sharing dependent applications; you must create a Component that inherits from AppComponent and make AppComponent expose the necessary common dependencies.
Now look at your module class:
@Module public class NetModule { @Provides @Singleton public NetworkingManager provideNetworkingManager(Application application) { return new NetworkingManager(application); } }
Here you are @Provide ing a NetworkingManager , this is normal. Your NetworkingManager requires an Application (a Context really), why not provide an App inside the NetworkingManager ? Or even better, why not provide a NetworkingManager inside the AppModule , since the AppModule should @Provide things that are common to the entire Application :
@Module public class AppModule { private Application app; public AppModule(Application app) { this.app = app; } @Provides @Singleton public Application application() { return app; } @Provides @Singleton public NetworkingManager provideNetworkingManager(Application application) { return new NetworkingManager(application); } }
Now in your App class:
public class App extends Application { private AppComponent appComponent; @Override public void onCreate() { super.onCreate(); appComponent = DaggerAppComponent .builder() .appModule(new AppModule(this)) .build(); appComponent.inject(this); } public AppComponent component() { return appComponent; } }
And in our hypothetical MainActivity :
public class MainActivity extends Activity { private AppComponent appComponent; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); appComponent = ((App)getApplicationContext()).getAppComponent(); appComponent.inject(this); } }
It seems that you are not using @Component(dependencies = {...}) correctly. dependencies used when you want to expose a dependency on one Component to another using the mechanism mentioned above.