Dagger 2 : When everything compiles, but the injected fields are still null

A very important thing to understand about Dagger 2 is how injection works with modules and components, A classic error is the following:

class HelperModule() {  
  @Provides provideMyValue(){
     return new MyValue();

@Component(modules = HelperModule.class)
public interface HelperComponent {  
    void injectActivity(Activity activity);

class MyActivity extends Activity {

    @Inject MyValue myValue;

    public void onCreate(SavedInstanceState state) {
                .helperModule(new HelperModule())


If you use something like this you will get a NullPointerException because myValue is still null, even though we did the injection just before.
The reason is explained in this part of Dagger documentation:

While a members-injection method for a type will accept instances of its subtypes, only Inject-annotated members of the parameter type and its supertypes will be injected; members of subtypes will not. For example, given the following types, only a and b will be injected into an instance of Child when it is passed to the members-injection method injectSelf(Self instance):

class Parent {
   @Inject A a;
 class Self extends Parent {
  @Inject B b;
 class Child extends Self {
   @Inject C c;

which means that every class that needs an injected variable need an inject() call in the Component but inject method will initialize all members up the inheritance chain.