Description
Is there an existing issue for this?
- I have searched the existing issues.
Which plugins are affected?
Messaging
Which platforms are affected?
Android
Description
My Flutter app crashes on Android when receiving Firebase push notifications — both in foreground and background.
Everything works fine on iOS. I’ve tried deleting the android folder and setting up again, but it still crashes consistently.
crash behaviour:
it shows a popup that says " isn't responding", with options to wait or close app.
debug console after crash
Thread[2,tid=3874,WaitingInMainSignalCatcherLoop,Thread*=0xb40000711baf8be0,peer=0x140048b8,"Signal Catcher"]: reacting to signal 3
I/24.bizconnect2( 3862):
I/24.bizconnect2( 3862): Wrote stack traces to tombstoned
current setup
-Flutter Version: 3.27.4 (channel stable)
-Android Gradle Plugin: 8.2.0
-Kotlin Version: 1.9.0
-google-services Plugin: 4.4.2
-Firebase Messaging Version: 15.2.5
-Test Devices: Multiple Android phones (physical device and emulators)
relevant code
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
FirebaseMessaging.onBackgroundMessage(firebaseMessagingBackgroundHandler);
final pushService = PushNotificationService();
pushService.requestNotificationPermissions();
pushService.init();
runApp(MyApp());
pushService.getFcmToken();
}
@pragma('vm:entry-point')
Future<void> firebaseMessagingBackgroundHandler(RemoteMessage message) async {
print('Handling background message: ${message.messageId}');
}
Android build.gradle (app-level):
plugins {
id "com.android.application"
id "kotlin-android"
id "dev.flutter.flutter-gradle-plugin"
id "com.google.gms.google-services"
}
dependencies {
implementation platform('com.google.firebase:firebase-bom:32.7.0')
implementation 'com.google.firebase:firebase-analytics'
implementation 'com.google.firebase:firebase-messaging'
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.4'
}
manifest
<service
android:name=".MyFirebaseMessagingService"
android:exported="false">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<meta-data
android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="@drawable/ic_notification" />
<meta-data
android:name="com.google.firebase.messaging.default_notification_channel_id"
android:value="high_importance_channel" />
I use Flutter's FirebaseMessaging.onMessage, onMessageOpenedApp, getInitialMessage, and a top-level firebaseMessagingBackgroundHandler I also register the background handler in main() before anything else
Things i've tried
-Verified google-services.json is present in the android/app directory
-Confirmed the package name in google-services.json matches my app's package name
-Updated all Firebase dependencies to the latest versions
-Verified the manifest has the proper FCM service declarations
-Tried both with and without the Firebase BOM
-Rebuilt and cleaned the project multiple times
-Verified Flutter Firebase plugins are correctly initialized in the Dart code
-Tried downgrading Google Services plugin versions
-Verified manifest includes required Firebase messaging services and permissions
-Tested with and without custom deep link payload
-Ensured firebaseMessagingBackgroundHandler is @pragma('vm:entry-point')
-Validated local notification handling logic in foreground
-Removed unnecessary platform-specific logic (no effect)
-Tried using a minimal PushNotificationService setup (still crashes)
-ic_notification.png is correctly placed in res/drawable
-FirebaseMessagingService.java exists
-Using FlutterLocalNotificationsPlugin for foreground display
-also tried with calling await Firebase.initializeApp in the toplevel background handler
running
~/Library/Android/sdk/platform-tools/adb logcat | grep -E "(flutter|Firebase|Exception|Error)"
and
~/Library/Android/sdk/platform-tools/adb logcat | grep Firebase
Doesn’t seem to bring any specific crash reason
Reproducing the issue
I setup firebase message with the instructions on the firebase console, then i send a notification to android
Firebase Core version
3.13.0
Flutter Version
3.27.4
Relevant Log Output
Wrote stack traces to tombstoned
D/EGL_emulation( 5615): app_time_stats: avg=27591.60ms min=93.07ms max=55090.13ms count=2
Flutter dependencies
Additional context and comments
No response