title: Dagger 2 - Injecting interface in implementation class - "Attempt to invoke interface method on a null object reference"
body: <p>I am always getting null pointer exception when I try to inject interface in implementation class. here is my code:</p>
  
  <p>Getting: </p>
  
  <blockquote>
    <p>Nullpointer error in <strong>LoginManagerImpl</strong> class at line:<br>
    @Override<br>
    public String getLoginResponse(String request) {<br>
      return networkManager.getLoginResponse(request);<br>
    }</p>
  </blockquote>
  
  <p>here <strong>networkManager is always null</strong>, can you please look into the code.</p>
  
  <p>Below is my source code:</p>
  
  <pre><code>public class LoginActivity extends Activity {
  
      @Inject
      NetworkManager networkManager;
  
      @Inject
      LoginManager loginManager;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
          getApplicationComponent().inject(this);
  
          loginManager.getLoginResponse("valid Login Request");
      }
  }
  
  public interface NetworkManager
  {
      String getLoginResponse(String request);
      String getUserDetailResponse(String request);
      String getABCResponse(String request);
  }
  
  public interface LoginManager
  {
      String getLoginResponse(String request);
  }
  
  public class LoginManagerImpl implements LoginManager {
      @Inject
      NetworkManager networkManager;
  
      public LoginManagerImpl(Context context)
      {
  
      }
  
      @Override
      public String getLoginResponse(String request) {
          return networkManager.getLoginResponse(request);
      }
  }
  
  public class NetworkManagerImpl implements NetworkManager {
  
      public NetworkManagerImpl(Context context)
      {
  
      }
      @Override
      public String getLoginResponse(String request) {
          return "valid login response fetched from server";
      }
  
      @Override
      public String getUserDetailResponse(String request) {
          return "valid user deails";
      }
  
      @Override
      public String getABCResponse(String request) {
          return "valid ABC request response";
      }
  }
  
  @Module
  public class AppModule {
  
      DaggerApplication application;
  
      public AppModule(DaggerApplication application) {
          this.application = application;
      }
  
      @Provides
      @Singleton
      DaggerApplication provideDaggerApplication() {
          return application;
      }
  
      @Provides
      @Singleton
      public Context provideApplicationContext()
      {
          return application.getApplicationContext();
      }
  
      @Provides
      @Singleton
      public LoginManager providesLoginManager(Context context)
      {
          return new LoginManagerImpl();
      }
  
      @Provides
      @Singleton
      public LoyaltyCardManager providesLoyaltyCardManager(Context context)
      {
          return new LoyaltyCardManagerImpl(context);
      }
  
      @Provides
      @Singleton
      public NetworkManager providesNetworkManager(Context context)
      {
          return new NetworkManagerImpl(context);
      }
  }
  
  @Singleton
  @Component(
          modules = {
                  com.dagger.component.AppModule.class
          })
  public interface ApplicationComponent {
      void inject (LoginActivity activity);
  
      NetworkManager getNetworkManager();
      LoginManager getLoginManager();
  }
  </code></pre>