How to check if a Firebase App is already initialized on Android

Solution 1:

On firebase web, you check if already initialized with:

if (firebase.apps.length === 0) {
    firebase.initializeApp({});
}

Solution 2:

In v9, Firebase has been modularized for better tree shaking. So we can no longer import entire app and check the apps property AFAIK. The below approach can be used instead.

import { initializeApp, getApps, getApp } from "firebase/app";
getApps().length === 0 ? initializeApp(firebaseConfig) : getApp();

https://firebase.google.com/docs/reference/js/v9/app.md#getapps for documentation