I am having an issue where my project runs fine on iOS, but on Android I get the following error:
PlatformException (PlatformException(channel-error, Unable to establish connection on channel., null, null))
Complete stack here:
✓ Built build/app/outputs/flutter-apk/app-debug.apk.
W/FlutterActivityAndFragmentDelegate(19624): A splash screen was provided to Flutter, but this is deprecated. See flutter.dev/go/android-splash-migration for migration steps.
Connecting to VM Service at ws://127.0.0.1:51576/EjKjPfki7E8=/ws
E/flutter (19624): [ERROR:flutter/lib/ui/ui_dart_state.cc(198)] Unhandled Exception: PlatformException(channel-error, Unable to establish connection on channel., null, null)
E/flutter (19624): #0 FirebaseCoreHostApi.initializeCore
package:firebase_core_platform_interface/…/pigeon/messages.pigeon.dart:199
E/flutter (19624): <asynchronous suspension>
E/flutter (19624): #1 MethodChannelFirebase._initializeCore
package:firebase_core_platform_interface/…/method_channel/method_channel_firebase.dart:29
E/flutter (19624): <asynchronous suspension>
E/flutter (19624): #2 MethodChannelFirebase.initializeApp
package:firebase_core_platform_interface/…/method_channel/method_channel_firebase.dart:73
E/flutter (19624): <asynchronous suspension>
E/flutter (19624): #3 Firebase.initializeApp
package:firebase_core/src/firebase.dart:40
E/flutter (19624): <asynchronous suspension>
E/flutter (19624): #4 main
package:cadsys_adm/main.dart:11
E/flutter (19624): <asynchronous suspension>
E/flutter (19624):
And the code causing the error is:
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
runApp(MyApp());
}
I'm only using two Firebase packages (from pubspec.yaml):
firebase_core: ^1.19.2
firebase_messaging: ^12.0.3
A similar question exists here, but none of the fixes work for me: Calling Firebase.initializeApp() returns 'Unable to establish connection on channel' - Flutter + Firebase
Has anyone come across any fix for this? Remember, it occurs ONLY on Android, not on iOS.