title: java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process
body: <p>I created a new project and added firebase via android studio tool of firebase. Did everything as instructed but I am getting this error during lunching the app.</p>
  
  <pre><code>Process: com.chitchat, PID: 20084
  java.lang.RuntimeException: Unable to start activity ComponentInfo{com.chitchat/com.chitchat.MainActivity}: java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process com.chitchat. Make sure to call FirebaseApp.initializeApp(Context) first.
      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2951)
      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3086)
      at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
      at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
      at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1816)
      at android.os.Handler.dispatchMessage(Handler.java:106)
      at android.os.Looper.loop(Looper.java:193)
      at android.app.ActivityThread.main(ActivityThread.java:6718)
      at java.lang.reflect.Method.invoke(Native Method)
      at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:495)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
   Caused by: java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process com.chitchat. Make sure to call FirebaseApp.initializeApp(Context) first.
      at com.google.firebase.FirebaseApp.getInstance(com.google.firebase:firebase-common@@16.0.1:219)
      at com.google.firebase.auth.FirebaseAuth.getInstance(Unknown Source:1)
      at com.chitchat.MainActivity.onCreate(MainActivity.java:22)
      at android.app.Activity.performCreate(Activity.java:7144)
      at android.app.Activity.performCreate(Activity.java:7135)
      at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1272)
      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2931)
      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3086) 
      at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78) 
      at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108) 
      at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68) 
      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1816) 
      at android.os.Handler.dispatchMessage(Handler.java:106) 
      at android.os.Looper.loop(Looper.java:193) 
      at android.app.ActivityThread.main(ActivityThread.java:6718) 
      at java.lang.reflect.Method.invoke(Native Method) 
      at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:495) 
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858) 
  </code></pre>
  
  <p>MainActivity.java is</p>
  
  <pre><code>public class MainActivity extends AppCompatActivity {
  
  private FirebaseAuth mAuth;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
  
      FirebaseApp.initializeApp(MainActivity.this);
      mAuth = FirebaseAuth.getInstance();
  }
  
  @Override
  public void onStart() {
      super.onStart();
      // Check if user is signed in (non-null) and update UI accordingly.
      FirebaseUser currentUser = mAuth.getCurrentUser();
      //updateUI(currentUser);
  
      if(currentUser == null){
          Intent startAct = new Intent(MainActivity.this, Start_Activity.class);
          startActivity(startAct);
          finish();
      }
  }
  }
  </code></pre>
  
  <p>and gradle.build is</p>
  
  <pre><code>apply plugin: 'com.android.application'
  apply plugin: 'com.google.gms.google-services'
  
  android {
      compileSdkVersion 28
      defaultConfig {
          applicationId "com.chitchat"
          minSdkVersion 23
          targetSdkVersion 28
          versionCode 1
          versionName "1.0"
          testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
      }
      buildTypes {
          release {
              minifyEnabled false
              proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
          }
      }
  }
  
  dependencies {
      implementation fileTree(dir: 'libs', include: ['*.jar'])
      implementation 'com.android.support:appcompat-v7:28.0.0'
      implementation 'com.android.support:design:28.0.0'
      implementation 'com.android.support.constraint:constraint-layout:1.1.3'
      implementation 'com.google.firebase:firebase-auth:16.0.3'
      implementation 'com.google.firebase:firebase-core:16.0.3'
      //implementation 'com.google.android.gms:play-services-base'
      testImplementation 'junit:junit:4.12'
      androidTestImplementation 'com.android.support.test:runner:1.0.2'
      androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
  
  
  }
  </code></pre>
  
  <p>Project-level gradle.build</p>
  
  <pre><code>    buildscript {
      repositories {
          google()
          jcenter()
  
      }
      dependencies {
          classpath 'com.android.tools.build:gradle:3.3.0'
          classpath 'com.google.gms:google-services:4.1.0'
  
          // NOTE: Do not place your application dependencies here; they belong
          // in the individual module build.gradle files
      }
  }
  
  allprojects {
      repositories {
          google()
          jcenter()
  
      }
  }
  
  task clean(type: Delete) {
      delete rootProject.buildDir
  }
  </code></pre>
  
  <p>Couldn't find anything on web! Have added <code>firebaseApp.initializeApp(this)</code> which was not present in any instructions but still the same error on emulator and on device.</p>