I'm working on a Flutter app using firebase_core, and everything runs fine in debug mode, but in release mode, I keep getting the following error on startup in android:
> 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)
#1 MethodChannelFirebase._initializeCore (package:firebase_core_platform_interface/src/method_channel/method_channel_firebase.dart:29)
#2 MethodChannelFirebase.initializeApp (package:firebase_core_platform_interface/src/method_channel/method_channel_firebase.dart:70)
#3 Firebase.initializeApp (package:firebase_core/src/firebase.dart:66)
#4 main (package:my_app/main.dart:XXX)
I'm initializing Firebase like this in main.dart:
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp(); // Also tried with options via flutterfire CLI
runApp(MyApp());
}
google-services.json is present in android/app/
I'm using the latest versions of:
firebase_core: ^4.1.1
firebase_messaging: ^16.0.2
when I run it in debug mode works fine but when I run app via flutter run --release then i got the error
[ERROR:flutter/runtime/dart_vm_initializer.cc(40)] Unhandled Exception: PlatformException(channel-error, Unable to establish connection on channel: "dev.flutter.pigeon.firebase_core_platform_interface.FirebaseCoreHostApi.initializeCore"., null, null)
How can I solve it?