Flutter "A Firebase App Named [DEFAULT] Already Exists": The 4-Step Fix
What does "[core/duplicate-app] A Firebase App named "[DEFAULT]" already exists" mean in Flutter?
It means a default Firebase app already exists when your Dart code calls Firebase.initializeApp(), and the options you pass don't match it. On Android and Apple platforms, the native Firebase SDK creates a default app named [DEFAULT] on its own when it finds google-services.json or GoogleService-Info.plist. The FlutterFire source code then compares three fields of your FirebaseOptions with that native app: apiKey, databaseURL and storageBucket. If any of them differs, it throws the duplicate-app error instead of returning the existing app. So the fix is almost never "initialize twice more carefully": it's making the native config file and firebase_options.dart point at the same Firebase app. This guide was checked against the firebase_core API docs, the Firebase Flutter setup guide and the FlutterFire source on GitHub on 2026-11-30.
The Config Match Fix: 4 steps
Short answer: find which two configs disagree, regenerate them from one Firebase project, clean the build, and add a name only when you really need a second app.
- Compare the two configs. Open
lib/firebase_options.dartand the native file for the platform that crashes:android/app/google-services.json(or a flavor folder such asandroid/app/src/dev/) andios/Runner/GoogleService-Info.plist. Check that the API key, project ID and storage bucket are the same in both. - Regenerate from one project. Delete the stale native file, then run
flutterfire configureand pick the same Firebase project and apps. The CLI writes a freshfirebase_options.dart, and the native files match it again. - Clean and cold start. Run
flutter clean,flutter pub getand a fullflutter run. A hot restart keeps the native default app alive, so it can't prove the fix. - Name a second app only on purpose. If you really need two Firebase projects in one build, keep
[DEFAULT]for one and give the other aname. Don't use a name to silence the error on your main app.
Why does Flutter throw duplicate-app instead of reusing the app?
Short answer: FlutterFire returns the existing default app only when its options are "roughly identical" to yours; different options mean two configs, and it refuses to guess which one you meant.
The initializeApp method in firebase_core_platform_interface handles the default app in three cases. If no native default app exists and you passed no options, it throws "no app has been created", the error covered in our guide to fixing "No Firebase App [DEFAULT] has been created". If a native default app exists and you passed options, it runs a soft check. If the options match, it returns the existing app.
The soft check compares only these fields, so these are the ones to look at:
| Field compared | When it causes duplicate-app | Where it usually differs |
|---|---|---|
apiKey | Always compared | Old google-services.json from another project or flavor |
databaseURL | Only if you pass one | Realtime Database added after the native file was downloaded |
storageBucket | Only if you pass one | Default bucket changed, or project switched |
The comments in that code also explain why it's lenient: small differences, such as platform keys missing during hot reloads and restarts, shouldn't throw. A different API key isn't a small difference. It means the native layer and Dart point at different Firebase apps, often in different projects. The same comparison runs for named apps, so initializing 'secondary' twice with different options throws duplicate-app for that name too.
Which situations cause it most often?
Short answer: a stale native config file after switching projects, flavors that share one bundle ID across projects, and calling initializeApp from more than one place.
- Project switched, file left behind. You moved the app to a client's Firebase project and updated
firebase_options.dart, but the oldgoogle-services.jsonor plist is still in the native folder. The native SDK builds[DEFAULT]from the old file and your Dart options carry the new key. - Flavors with their own native files. Files under
android/app/src/<flavor>/or per-scheme plists inios/win for that build. If the Dart side uses one generated options file for every flavor, at least one flavor won't match. - The same bundle ID in two projects. When dev and prod Firebase projects both register the same iOS bundle ID, the plist and the Dart options can come from different projects without anyone noticing.
- Initializing in two places. A background message handler, a second isolate or a package that calls
Firebase.initializeAppwith its own options can hit the native app with different values. Initialize once inmain()with the sameDefaultFirebaseOptions.currentPlatformeverywhere.
Is wrapping initializeApp in a try/catch or checking Firebase.apps a real fix?
Short answer: no. Both hide the error, and the app keeps running against whichever config the native layer loaded.
Firebase.apps returns every app instance that has been created, so a guard like "only initialize if Firebase.apps is empty" does skip the second call. But if the native default app was built from a stale file, your Auth, Firestore and Storage calls now go to the wrong project or bucket. That shows up later as permission errors or missing data, such as the cases in our list of Firestore permission-denied causes, which are far harder to trace than the original crash. Swallowing the exception in an empty catch has the same effect. Use a guard only after the configs match, if a package you don't control initializes Firebase first.
When should you pass a name to initializeApp?
Short answer: only when the build really talks to two Firebase projects at once, for example reading a shared config project alongside the app's own project.
The firebase_core docs say the default app is created by passing no name. A named app is a secondary app: it needs its own options, and plugins only use it when you pass it in, for example FirebaseFirestore.instanceFor(app: secondaryApp). Naming your main app to dodge the error leaves [DEFAULT] built from the native file, so any plugin that uses the default instance still uses the old config. Several Stack Overflow answers suggest the name trick; it stops the crash but doesn't make the two configs agree.
// Only when you really need a second project:
final secondary = await Firebase.initializeApp(
name: 'shared-config',
options: SharedConfigOptions.currentPlatform,
);
How do you check the fix held?
Short answer: cold-start every flavor on a real device, then confirm the app talks to the project you expect.
- Run each flavor with a full
flutter run --flavor <name>, not a hot restart, on Android and iOS. - Log
Firebase.app().options.projectIdonce at startup in debug builds and check it matches the Firebase console for that flavor. - Build in release mode too, because some config problems only appear there; our list of reasons a Flutter app works in debug but not in release covers the usual ones.
- Before a Play upload, walk through our Flutter and Firebase release checklist, which includes checking that each build points at the right Firebase project.
We build and ship Flutter apps with Firebase on Google Play at GSPTeck, giosaia's indie studio building mobile and web apps with Flutter and Firebase, and keeping dev and prod configs apart is part of every release.
FAQ
Why does the error appear only on iOS or only on Android?
Each platform has its own native config file. If only the plist or only google-services.json is stale, only that platform builds a default app that doesn't match your Dart options.
Does the error happen on Flutter web?
Web has no google-services.json or plist, so the native default app case doesn't apply. It can still appear if initializeApp runs twice with different options in the same page.
Will flutter clean alone fix it?
Only if the configs already match and an old build was the problem. If the stale native file is still in the project, the error comes back on the next cold start.
Is it safe to delete google-services.json when I use firebase_options.dart?
Only if you run flutterfire configure right after, so the native files are regenerated for the project you picked. Android builds that apply the Google services Gradle plugin fail without google-services.json, so never leave it missing.
Sources
- firebase_core API: Firebase.initializeApp (checked 2026-11-30)
- firebase_core API: Firebase.apps (checked 2026-11-30)
- Firebase: add Firebase to your Flutter app with flutterfire configure (checked 2026-11-30)
- FlutterFire source: method_channel_firebase.dart, the options check that throws duplicate-app (checked 2026-11-30)
- Stack Overflow: A Firebase App named "[DEFAULT]" already exists (checked 2026-11-30)