title: dagger2 non-@Nullable @Provides method
body: <p>I'm at the beginning of use Dagger to my projects. 
  I've made this modules:</p>
  
  <pre><code>@Module
  public class FirebaseModule {
  
  @Provides @Singleton
  public FirebaseUser provideCurrentUser(){
      return FirebaseAuth.getInstance().getCurrentUser();
  }
  
  @Provides @Singleton
  public DatabaseReference provideDatabaseReference(){
      return FirebaseDatabase.getInstance().getReference();
  }
  
  @Provides @Singleton
  public FirebaseAuth provideFirebaseAuth(){
      return FirebaseAuth.getInstance();
  }
  }
  </code></pre>
  
  <p>and this:</p>
  
  <pre><code>@Module
  public class AppModule
  {
  private HappyParkApp app;
  
  public AppModule(HappyParkApp app) {
      this.app = app;
  }
  
  @Provides
  public HappyParkApp providesApp()
  {
  return this.app;
  }
  
  @Provides
  public Context getAppContext(){
      return this.app;
  }
  }
  </code></pre>
  
  <p>I've also made the component:</p>
  
  <pre><code>@Singleton
  @Component(modules = {AppModule.class,
                        FirebaseModule.class})
  public interface AppComponent {
  
      void inject(MainActivity activity);
  }
  </code></pre>
  
  <p>and this is the appComponent implemented in the application:</p>
  
  <pre><code>public class HappyParkApp extends Application {
  
  private AppComponent appComponent;
  private static HappyParkApp instance = new HappyParkApp();
  @Override
  public void onCreate() {
      super.onCreate();
      createAppComponent();
  }
  
  public static HappyParkApp getInstance() {
      return instance;
  }
  
  public AppComponent createAppComponent() {
   if(appComponent == null){
       appComponent = DaggerAppComponent.builder()
               .appModule(new AppModule(this))
               .firebaseModule(new FirebaseModule()).build();
   }
  
   return appComponent;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>so I've tried to to this in <code>onCreate()</code> method of MainActivity:</p>
  
  <pre><code>HappyParkApp.getInstance().createAppComponent().inject(this);
  </code></pre>
  
  <p>and this before:</p>
  
  <pre><code> @Inject
  FirebaseUser user;
  
  @Inject
  DatabaseReference reference;
  
  @Inject
  FirebaseAuth mAuth;
  </code></pre>
  
  <p>but I'm getting this error:</p>
  
  <pre><code> Caused by: java.lang.NullPointerException: Cannot return null from a non-@Nullable @Provides method
  </code></pre>
  
  <p>at this line:</p>
  
  <pre><code> HappyParkApp.getInstance().createAppComponent().inject(this);
  </code></pre>
  
  <p>and I don't know how to fix it: what is the error? Is this a wrong injection?</p>
  
  <p>Thank you</p>