flutterfire icon indicating copy to clipboard operation
flutterfire copied to clipboard

[firebase_core]: Firebase.initializeApp Start application error

Open yys50 opened this issue 1 year ago • 30 comments

Is there an existing issue for this?

  • [x] I have searched the existing issues.

Which plugins are affected?

No response

Which platforms are affected?

iOS

Description

[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(channel-error, Unable to establish connection on channel: "dev.flutter.pigeon.firebase_core_platform_interface.FirebaseCoreHostApi.initializeCore"., null, null) #0 FirebaseCoreHostApi.initializeCore (package:firebase_core_platform_interface/src/pigeon/messages.pigeon.dart:301:7) #1 MethodChannelFirebase._initializeCore (package:firebase_core_platform_interface/src/method_channel/method_channel_firebase.dart:29:41) #2 MethodChannelFirebase.initializeApp (package:firebase_core_platform_interface/src/method_channel/method_channel_firebase.dart:70:7) #3 Firebase.initializeApp (package:firebase_core/src/firebase.dart:66:31)

firebase_core: ^3.15.1 firebase_core_platform_interface: ^6.0.0

Reproducing the issue

Connected to the VM Service. [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(channel-error, Unable to establish connection on channel: "dev.flutter.pigeon.firebase_core_platform_interface.FirebaseCoreHostApi.initializeCore"., null, null) #0 FirebaseCoreHostApi.initializeCore (package:firebase_core_platform_interface/src/pigeon/messages.pigeon.dart:301:7) messages.pigeon.dart:301 #1 MethodChannelFirebase._initializeCore (package:firebase_core_platform_interface/src/method_channel/method_channel_firebase.dart:29:41) method_channel_firebase.dart:29 #2 MethodChannelFirebase.initializeApp (package:firebase_core_platform_interface/src/method_channel/method_channel_firebase.dart:70:7) method_channel_firebase.dart:70 #3 Firebase.initializeApp (package:firebase_core/src/firebase.dart:66:31) firebase.dart:66

Firebase Core version

3.15.1

Flutter Version

3.24.4

Relevant Log Output


Flutter dependencies

Expand Flutter dependencies snippet

Replace this line with the contents of your `flutter pub deps -- --style=compact`.

Additional context and comments

No response

yys50 avatar Jul 18 '25 13:07 yys50

Hi there, can you show me a snippet of what you are doing and can you confirm you have followed the setup instructions here https://firebase.google.com/docs/flutter/setup?platform=android ?

MichaelVerdon avatar Jul 18 '25 13:07 MichaelVerdon

I got the same issue when using firebase_core: 3.15.2 This is the code that throw the error:

 await Firebase.initializeApp(
        options: DefaultFirebaseOptions.currentPlatform);

thanhdatvo avatar Jul 21 '25 23:07 thanhdatvo

Just to give an update: The issue disappeared after I ran this command:

flutter clean && flutter pub get

thanhdatvo avatar Jul 21 '25 23:07 thanhdatvo

We are getting this same issue in our project. We noticed this problem last week and no code changes were made to our repo. We have done pretty through cleaning and re-installing of dependencies with no luck. @thanhdatvo we didn't run that command together but we typically run through the following steps when switching between different projects that we manage:

Delete pubspec.lock file Delete Podfile.lock file Delete Pods folder

Then in Terminal:

flutter pub cache clean
flutter clean
flutter pub get
cd ios
pod deintegrate
pod cache clean --all
pod install (if script yells at you to run pod install --repo-update, do that instead)

Also delete Derived Data folder

^^^ These steps have been learned from tons of headaches around switching projects and navigating build/dependency related errors.

We are on:

firebase_core version: 3.15.0 flutter version: 3.24.2

Curious to know if this is a wider problem and is happening to more people. We are going to try to upgrade firebase_core and/or pigeon and see if that helps. Any insight would be greatly appreciated!

benjigold avatar Jul 24 '25 21:07 benjigold

@benjigold my current flutter version:

Flutter 3.34.0-0.0.pre • channel beta  

You may want to give it a try!

thanhdatvo avatar Jul 24 '25 22:07 thanhdatvo

I have the same issue, but on Android. How did you fix @benjigold ?

spiderion avatar Jul 27 '25 19:07 spiderion

Tried upgrading to 3.34.0-0.0.pre but still no luck @thanhdatvo

spiderion avatar Jul 27 '25 20:07 spiderion

To mention that in my case it only happens in release mode, in debug it works fine.

spiderion avatar Jul 27 '25 22:07 spiderion

Hi all, I’m unable to reproduce this issue on my end. Could you please share a minimal reproducible repository that I can clone to investigate further?

SelaseKay avatar Jul 28 '25 05:07 SelaseKay

Hi @SelaseKay, Thanks for your willingness to help. Do you have a working sample where we can make changes? I don't have the time to create a simple one from scratch, and the existing samples I find on gitgub are using legacy code that is no longer compatible with the new flutter versions.

spiderion avatar Jul 28 '25 08:07 spiderion

Hi @spiderion, you can reference the firebase_core example app.

SelaseKay avatar Jul 28 '25 08:07 SelaseKay

Hi @SelaseKay, I am on it, I was not yet able to reproduce on the example app but I am looking in the package and I could find the string of the error I am getting in my project
(dev.flutter.pigeon.firebase_core_platform_interface.FirebaseCoreHostApi.initializeCore) Under the folder windows, I don't know if it's related.

spiderion avatar Jul 28 '25 09:07 spiderion

final List<Object?>? pigeonVar_replyList = await pigeonVar_sendFuture as List<Object?>?; Returns null in my project. So the exception is thrown:

PlatformException _createConnectionError(String channelName) { return PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel: "$channelName".', ); }

spiderion avatar Jul 28 '25 10:07 spiderion

Issue_firebase.patch

@SelaseKay I managed to reproduce. Please apply the patch code in your Android Studio to the example app

when I remove the package ffmpeg_kit_flutter_new: ^3.0.1 the issue disapears

spiderion avatar Jul 28 '25 14:07 spiderion

Image

This also fixes the issue

spiderion avatar Jul 28 '25 16:07 spiderion

Build runs fine on debug mode. Only occurs in release mode for Android.

Flutter version - 3.24.4

firebase_core: ^4.0.0 firebase_messaging: ^16.0.0 firebase_remote_config: ^6.0.0 firebase_auth: ^6.0.0 ffmpeg_kit_flutter_new: ^3.0.1

sagar-rawat-aisensy avatar Jul 29 '25 09:07 sagar-rawat-aisensy

Image This also fixes the issue

Tried this, didn't work for me.

sagar-rawat-aisensy avatar Jul 29 '25 09:07 sagar-rawat-aisensy

Started working after removing this package

ffmpeg_kit_flutter_new: ^3.0.1

any other workaround? @spiderion

Issue_firebase.patch

@SelaseKay I managed to reproduce. Please apply the patch code in your Android Studio to the example app

when I remove the package ffmpeg_kit_flutter_new: ^3.0.1 the issue disapears

sagar-rawat-aisensy avatar Jul 29 '25 09:07 sagar-rawat-aisensy

@sagar-rawat-aisensy they just released a new Firebase. Please try to see if that fixes the issue.

spiderion avatar Jul 29 '25 09:07 spiderion

@spiderion already using the latest firebase_core firebase_core: ^4.0.0

sagar-rawat-aisensy avatar Jul 29 '25 09:07 sagar-rawat-aisensy