# FirebaseException: Firebase App named '[DEFAULT]' already exists

- **ID:** `flutter/firebase-app-not-initialized`
- **Domain:** flutter
- **Category:** config_error
- **Verification:** ai_generated
- **Fix Rate:** 95%

## Root Cause

Calling Firebase.initializeApp() multiple times without checking if the default app is already initialized.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| Flutter 3.22.0 | active | — | — |
| firebase_core 2.27.0 | active | — | — |
| firebase_auth 4.17.0 | active | — | — |

## Workarounds

1. **Check if Firebase is already initialized before calling initializeApp: `if (Firebase.apps.isEmpty) { await Firebase.initializeApp(); }`.** (95% success)
   ```
   Check if Firebase is already initialized before calling initializeApp: `if (Firebase.apps.isEmpty) { await Firebase.initializeApp(); }`.
   ```
2. **Initialize Firebase only once in the main() function before runApp: `WidgetsFlutterBinding.ensureInitialized(); await Firebase.initializeApp(); runApp(MyApp());`.** (90% success)
   ```
   Initialize Firebase only once in the main() function before runApp: `WidgetsFlutterBinding.ensureInitialized(); await Firebase.initializeApp(); runApp(MyApp());`.
   ```
3. **Use a singleton pattern to wrap Firebase initialization and prevent duplicate calls.** (85% success)
   ```
   Use a singleton pattern to wrap Firebase initialization and prevent duplicate calls.
   ```

## Dead Ends

- **** — Each call attempts to reinitialize, causing the 'already exists' error on subsequent calls. (90% fail)
- **** — Ignoring the error may lead to duplicate Firebase instances and unexpected behavior. (80% fail)
- **** — Firebase apps cannot be deleted programmatically; this approach is not supported. (95% fail)
