FirebaseApp name [DEFAULT] already exists
<p>I'm trying to manually initialize <code>FirebaseApp</code> on Application but getting this error.</p>

<pre><code>public class BaseApplication extends Application {

    @Override
    public void onCreate() {
        super.onCreate();
        FirebaseOptions firebaseOptions = new FirebaseOptions.Builder()
              .setDatabaseUrl("[DATABASE_URL]")
              .setApiKey("API_KEY")
              .setApplicationId("PROJECT_ID").build();
        FirebaseApp.initializeApp(getApplicationContext(),firebaseOptions);

        if (!FirebaseApp.getApps(this).isEmpty()) {
            FirebaseDatabase.getInstance().setPersistenceEnabled(true);
        }
    }
</code></pre>

<p>Assume that I set the <code>firebaseOptions</code> value accordingly.
I am expecting that this will set values for <code>FirebaseApp</code>.</p>

<p>Did I missed something? <a href="https://developers.google.com/android/reference/com/google/firebase/FirebaseApp.html#getApps(android.content.Context)" rel="noreferrer">FirebaseApp Documentation</a></p>

<blockquote>
  <p>The default app instance is initialized on app startup by
  FirebaseInitProvider. This is added to the app's manifest by Gradle
  manifest merging. If the app is using a different build system the
  provider needs to be manually added to the app's manifest.</p>
  
  <p>Alternatively initializeApp(Context, FirebaseOptions) initializes the
  default app instance. This method should be invoked from Application.
  This is also necessary if it is used outside of the application's main
  process.</p>
</blockquote>

<pre><code>   FATAL EXCEPTION: main
    Process: com.sample.android, PID: 5490
    java.lang.RuntimeException: Unable to create application com.android.tools.fd.runtime.BootstrapApplication: java.lang.IllegalStateException: FirebaseApp name [DEFAULT] already exists!
    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4331)
    at android.app.ActivityThread.access$1500(ActivityThread.java:135)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:136)
    at android.app.ActivityThread.main(ActivityThread.java:5001)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:801)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:617)
    at dalvik.system.NativeStart.main(Native Method)
    Caused by: java.lang.IllegalStateException: FirebaseApp name [DEFAULT] already exists!
    at com.google.android.gms.common.internal.zzab.zza(Unknown Source)
    at com.google.firebase.FirebaseApp.initializeApp(Unknown Source)
    at com.sample.android.activities.BcodeApplication.onCreate(BcodeApplication.java:21)
    at com.android.tools.fd.runtime.BootstrapApplication.onCreate(BootstrapApplication.java:369)
    at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1007)
    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4328)
    at android.app.ActivityThread.access$1500(ActivityThread.java:135) 
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256) 
    at android.os.Handler.dispatchMessage(Handler.java:102) 
    at android.os.Looper.loop(Looper.java:136) 
    at android.app.ActivityThread.main(ActivityThread.java:5001) 
    at java.lang.reflect.Method.invokeNative(Native Method) 
    at java.lang.reflect.Method.invoke(Method.java:515) 
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:801) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:617) 
    at dalvik.system.NativeStart.main(Native Method) 
</code></pre>