Flutter: Firebase.initializeApp fails with Unable to establish connection on channel
Unable to establish connection on channelShort answer
The Dart side of firebase_core could not reach its native half. That usually means the app was not fully rebuilt after adding Firebase, Firebase was never configured with flutterfire configure, or main() calls initializeApp before the Flutter binding exists. Fix the setup code, then stop the app and run it again.
Fix it fast
1Find out which cause you have
Compare your main() with the one in the Firebase setup guide, then check that firebase_options.dart exists.
sed -n 1,30p lib/main.dart && ls lib/firebase_options.dart2Match what you see, then jump to its fix
- 1
The error appears right after flutter pub add firebase_core, with the old app still runningThe app was hot-reloaded, not rebuilt, after adding FirebaseFix - 2
lib/firebase_options.dart does not exist or main.dart does not pass optionsFirebase is not configured for this appFix - 3
initializeApp is called inside a non-async main, or before WidgetsFlutterBinding.ensureInitializedmain() does not follow the documented initialization orderFix - 4
The error is Android only, and android/app/google-services.json is missingThe Android build has no Google services plugin or config fileFix
- 1
What does the error look like?
Unable to establish connection on channel
Cause 1 of 4
The app was hot-reloaded, not rebuilt, after adding Firebase
1Check
Native plugin code only exists in a new build. Check that the plugin is in pubspec.lock.
grep -n "firebase_core" pubspec.lock2Fix
Stop the running app completely and run it again, so Gradle and Xcode build the plugin.
flutter pub get
flutter run3Verify
initializeApp completes without an exception.
flutter run -vConfirmed by firebase.google.com
Cause 2 of 4
Firebase is not configured for this app
1Check
flutterfire configure creates firebase_options.dart in lib/. Look for it and for the options argument.
grep -n "DefaultFirebaseOptions" lib/main.dart2Fix
Log in, activate the FlutterFire CLI, run configure, and pass the generated options to initializeApp.
firebase login
dart pub global activate flutterfire_cli
flutterfire configure3Verify
lib/firebase_options.dart exists and the app starts.
ls lib/firebase_options.dartConfirmed by firebase.google.com
Cause 3 of 4
main() does not follow the documented initialization order
1Check
Read main() and confirm the binding call comes first and main is async.
grep -n -B3 -A6 "void main\|Future<void> main" lib/main.dart2Fix
Use the same order as the setup guide: ensureInitialized, awaited initializeApp with options, then runApp.
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform,
);
runApp(const MyApp());
}3Verify
Cold start the app; the exception should not return.
flutter runConfirmed by firebase.google.com
Cause 4 of 4
The Android build has no Google services plugin or config file
1Check
The file must be in the app module, and the Gradle plugin must be applied.
ls android/app/google-services.json2Fix
Run flutterfire configure again, and confirm the plugin is declared as the Android setup guide shows.
flutterfire configure3Verify
Build for Android and start the app.
flutter runConfirmed by firebase.google.com
How do I stop it coming back?
- Add each Firebase plugin with flutter pub add, then run flutterfire configure and do a full rebuild.
- Commit firebase_options.dart so every teammate starts from the same configuration.
- Keep Firebase.initializeApp as the first awaited call in main().
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
Back end
Firebase says no default app exists when you call a service
FirebaseAppError: The default Firebase app does not exist. Make sure you call initializeApp() before using any of the Firebase services.
A Firebase service was asked for the default app before initializeApp ran in that same module scope, or on a different copy of the package.
3 causes, each with a fixMobile apps
flutterfire configure fails in the terminal with command not found
flutterfire: command not found
FlutterFire CLI is a Dart tool installed separately.
2 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 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: 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 fix