Flutter: FirebaseOptions cannot be null when creating the default app
FirebaseOptions cannot be null when creating the default app.Short answer
Firebase started without any project settings. Either initializeApp was called without options on a platform that has no native config file, or the Android Google services plugin never turned google-services.json into settings. Run flutterfire configure, pass DefaultFirebaseOptions.currentPlatform, and check the Android plugin.
Fix it fast
1Find out which cause you have
See how your main() starts Firebase, and whether the generated options file exists.
grep -n "initializeApp" lib/main.dart ls lib/firebase_options.dart2Match what you see, then jump to its fix
- 1
Firebase.initializeApp() with empty parentheses, or no lib/firebase_options.dartinitializeApp is called without optionsFix - 2
It works on one platform and fails on another one you added laterfirebase_options.dart was made before this platform was addedFix - 3
Android only, and the app has no options argument or the plugin line is missingOn Android, google-services.json never became settingsFix
- 1
What does the error look like?
FirebaseOptions cannot be null when creating the default app.
Cause 1 of 3
initializeApp is called without options
1Check
The Flutter setup guide generates firebase_options.dart with flutterfire configure and passes its options to initializeApp. A bare call gives Firebase nothing to read on platforms without a native config file.
sed -n '1,25p' lib/main.dart2Fix
Generate the file, then pass the options. Call WidgetsFlutterBinding.ensureInitialized() before the awaited initialization.
dart pub global activate flutterfire_cli
flutterfire configure
// lib/main.dart
import 'package:firebase_core/firebase_core.dart';
import 'firebase_options.dart';
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform,
);
runApp(const MyApp());
}3Verify
Stop the app completely and run it again; the error should not return.
flutter runConfirmed by firebase.google.com
Cause 2 of 3
firebase_options.dart was made before this platform was added
1Check
The setup guide says to run flutterfire configure again whenever you add a platform. Open the generated file and look for a section for the platform that fails.
grep -n "static const FirebaseOptions" lib/firebase_options.dart2Fix
Run the configure command again and select every platform you ship.
flutterfire configure3Verify
The file now lists options for that platform. Rebuild and run it.
flutter runConfirmed by firebase.google.com
Cause 3 of 3
On Android, google-services.json never became settings
1Check
Firebase's Android guide puts google-services.json in the app module folder and applies the Google services Gradle plugin, which reads it. Check both.
ls android/app/google-services.json
grep -rn "google-services" android/app/build.gradle* android/build.gradle* android/settings.gradle*2Fix
Put the file in android/app and apply the plugin id com.google.gms.google-services in the app module's plugins block, declared with a version at the project level. The package name in the file must match your app's application ID.
// android/app/build.gradle.kts
plugins {
id("com.android.application")
id("com.google.gms.google-services")
}3Verify
Clean and rebuild so the plugin runs again.
flutter clean
flutter runConfirmed by firebase.google.com
How do I stop it coming back?
- Treat firebase_options.dart as generated code and commit it, then rerun flutterfire configure when platforms change.
- Always await initializeApp before runApp.
- Match the Android application ID to the one registered in Firebase.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
- SessionBirdAn omnichannel engagement suite in Flutter: campaigns, chatbot, tickets, analytics and live calling.
- WorkforceA field app, an admin console and a self-hosted Node.js server for push and reconciliation.
- Spotless LaundryAn on-demand laundry app: Flutter on a Laravel back end, with Firebase for live updates.
Related fixes
Mobile apps
Flutter Android: Failed to load FirebaseOptions from resource
Failed to load FirebaseOptions from resource. Check that you have defined values.xml correctly.
On Android, Firebase reads its settings from a values.xml file that the Google services Gradle plugin builds from google-services.json.
4 causes, each with a fixMobile apps
Flutter: Firebase.initializeApp fails with Unable to establish connection on channel
Unable to establish connection on channel
The Dart side of firebase_core could not reach its native half.
4 causes, each with a fixMobile apps
Gradle cannot find com.google.firebase:firebase-analytics-ktx
Required by: project :app
Firebase moved the Kotlin extensions into the main modules and stopped releasing the -ktx modules in July 2025.
2 causes, each with a fixMobile apps
Firestore returns permission-denied: Missing or insufficient permissions
FirebaseError: [code=permission-denied]: Missing or insufficient permissions.
Firestore rejected the request because your security rules, or App Check enforcement, did not allow it.
4 causes, each with a fixMobile apps
Flutter: FirebaseException No AppCheckProvider installed
com.google.firebase.FirebaseException: No AppCheckProvider installed
Firebase App Check needs a provider chosen in your Dart code before other Firebase calls run.
3 causes, each with a fixMobile apps
FirebaseMessaging.getAPNSToken() returns null on iOS
FirebaseMessaging.instance.getAPNSToken() returns null
getAPNSToken() gives null when iOS has not handed the app an APNs token yet or never will.
4 causes, each with a fix