Skip to content

FIREBASE-MESSAGING : App stops responding when it receives a notification on Android #17350

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
1 task done
Eunice-nma opened this issue May 13, 2025 · 1 comment
Open
1 task done
Labels
blocked: customer-response Waiting for customer response, e.g. more information was requested. platform: android Issues / PRs which are specifically for Android. plugin: messaging type: bug Something isn't working

Comments

@Eunice-nma
Copy link

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

@Eunice-nma Eunice-nma added type: bug Something isn't working Needs Attention This issue needs maintainer attention. labels May 13, 2025
@SelaseKay SelaseKay added plugin: messaging platform: android Issues / PRs which are specifically for Android. labels May 13, 2025
@SelaseKay
Copy link
Contributor

Hi @Eunice-nma, I tested this using the firebase_messaging example app and it appears to work as expected. Could you provide a minimal reproducible repository that I can clone to investigate further? Additionally, if there are more crash logs available, please share the full output.

@SelaseKay SelaseKay added blocked: customer-response Waiting for customer response, e.g. more information was requested. and removed Needs Attention This issue needs maintainer attention. labels May 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked: customer-response Waiting for customer response, e.g. more information was requested. platform: android Issues / PRs which are specifically for Android. plugin: messaging type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants