1

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?

3 Answers 3

4

I was facing the same issue and managed to work around it by disabling code and resource shrinking in the Gradle build file.

In android/app/build.gradle, inside the buildTypes { release { ... } } block, set both options to false:

buildTypes {
    release {
        minifyEnabled false
        shrinkResources false
    }
}

After doing this, the issue was resolved.

However, this isn’t an ideal solution since it disables important optimizations (like reducing APK size). I haven’t found a proper fix yet, but this workaround can help you get the build running in the meantime.

Sign up to request clarification or add additional context in comments.

Comments

0

I haven't found any solution yet so i have downgraded the flutter version and it is working fine with lower version

1 Comment

Which flutter version you are doing? Im having the same problem despite trying out many different method. It just don't work on the flutter run --release.
0

If someone encounters this issue and nothing seems to help, take a look at Logcat. In my case, the problem wasn’t in the package that Flutter logs were pointing to at all. It was resolved by adding the proper ProGuard rules.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.