Android Connecting @Modules with @Inject


Example

The connection between the provider of dependencies, @Module, and the classes requesting them through @Inject is made using @Component, which is an interface:

import javax.inject.Singleton;
import dagger.Component;

@Singleton
@Component(modules = {VehicleModule.class})
public interface VehicleComponent {
    Vehicle provideVehicle();
}

For the @Component annotation, you have to specify which modules are going to be used. In this example VehicleModule is used, which is defined in this example. If you need to use more modules, then just add them using a comma as a separator.