Where are you actually injecting ClassWithoutInjects
?
The injects
on the Module refers to classes that will request dependencies from the provided by that module.
So in this case, Dagger is expecting ClassWithoutInjects
to request dependencies from the ObjectGraph, with dependencies provided by this module (which is currently empty).
If you wanted to provide ClassWithoutInjects
as a dependency, and not as consumer of the dependencies (which is what it is setup as in the module), either add the @Inject
on it's constructor, or add an explicit provider method in the module.
@Module
public class SimpleModule {
@Provides ClassWithoutInjects provideClassWithoutInjects() {
return new ClassWithoutInjects();
}
}
If ClassWithoutInjects
is a consumer of dependencies.
@Module(injects = ClassWithoutInjects.class)
public class SimpleModule {
// Any dependencies can be provided here
// Not how ClassWithoutInjects is not a dependency, you can inject dependencies from
// this module into it (and get compile time verification for those, but you can't
// provide ClassWithoutInjects in this configuration
}
public class ClassWithoutInject {
// Inject dependencies here
}