Firebase onMessageReceived is crashing the application


Does anyone faced with the similar problem before? Whenever I send message, app is crashing immediately. Here is my MessageReceiver class:

public class MessageReceiver extends FirebaseMessagingService {
        final String TAG = "MessageReceiver";
        public void onMessageReceived(RemoteMessage remoteMessage) {

            Log.d(TAG, "onMessageReceived: "+remoteMessage.getFrom());

            if(remoteMessage.getData().size() >0){
                Log.d(TAG,"payload: "+remoteMessage.getData());

I even tried with empty method onMessageReceived still crushing the app.

This is the version that Im compiling:

compile ''

This is the json that Im sending to app through PostMan:




I figure it out. If anyone face with the similar problem in the feature you need to make sure that you also compile firebase-core along firebase-messaging and that you match the same version with google play services.

 compile ''
 compile ''

After this everything worked fine. Thanks @FnR for your suggestions.

Edit 9th June 2022

This are the current most latest versions:

 implementation ''
 implementation ''

Also want to mention that it is a good practice to use now Firebase Android BoM (Bill of materials) to manage your Firebase dependencies, where the versions will be taken care of for you.

dependencies {
      // Import the BoM for the Firebase platform
      implementation platform('')
      // Declare the dependencies for the desired Firebase products without specifying versions
      // For example, declare the dependencies for Firebase Authentication and Cloud Firestore
      implementation ''
      implementation ''

The above snippet is from Firebase docs, please for more info see:

Answered By – Alexander

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published