Mxo.

iOS and Android Errors After Installing Firebase in Your Project

Setting up Firebase in Flutter is pretty intuitive — simple, really. You only have to follow these docs to get there.

The problem, however, starts when you’ve done this:

void main() async {
  await Firebase.initializeApp();
  runApp(MyApp());
}

…and you hit flutter run. You’ll likely encounter two errors related to Firebase. Here’s how to handle them properly.

Assumes your pubspec.yaml has the necessary firebase_* packages set, and you’ve verified with:

flutter doctor -v

You can also check the platform-specific deployment docs:


Android

Error:

PlatformException(channel-error,
Unable to establish connection on channel: 
"dev.flutter.pigeon.firebase_auth_platform_interface.FirebaseAuthHostApi.registerIdTokenListener")

Fix:

This error is caused by a mismatch between Flutter’s configured NDK version and Firebase’s minimum required NDK version.

Open: android/app/build.gradle.kts

android {
    namespace = "com.example.mockify"
    compileSdk = flutter.compileSdkVersion
    ndkVersion = "27.0.12077973" // <- update to minimum required
    defaultConfig {
        minSdk = 23 // <- required by Firebase Auth
    }
}

Also run:

flutter doctor --android-licenses

iOS

Problem:

You’ve updated your deployment target in Xcode but Firebase still complains.

Fix:

  1. Open your project in Xcode:
cd ios && open Runner.xcworkspace
  1. Then in ios/Podfile, update this line:
platform :ios, '13.0' # <- set to Firebase's required minimum
  1. Clean and rebuild everything:
flutter clean
rm ios/Podfile.lock
rm -rf ios/Pods
rm -rf ios/.symlinks
rm -rf ios/Flutter/Flutter.framework
rm -rf ios/Flutter/Flutter.podspec
flutter pub get
cd ios
pod install
cd ..

Long-Term Maintenance

Every time you update Firebase dependencies or Flutter SDK:

flutter doctor --android-licenses

Re-check:

  • minSdkVersion (Android)
  • platform :ios (iOS)
  • ndkVersion (Android)

Reference Docs