The application unexpectedly closes upon receiving a notification while using @react-native-firebase/messaging

I'm currently working on setting up notifications using @react-native-firebase/messaging in a React Native app. I'm able to retrieve the FCM token, but the app crashes when a notification is received.

Here's the error I found in Crashlytics:

Unable to instantiate service io.invertase.firebase.messaging.RNFirebaseMessagingService: java.lang.ClassNotFoundException: Didn't find class "io.invertase.firebase.messaging.RNFirebaseMessagingService" on path: DexPathList

Below are the versions of libraries used in the app:

"@react-native-firebase/analytics": "^7.6.7",
"@react-native-firebase/app": "^8.4.3",
"@react-native-firebase/crashlytics": "^8.4.9",
"@react-native-firebase/messaging": "^7.8.11",
"react": "16.13.1",
"react-native": "^0.63.3",

Content of android/build.gradle:

// Top-level build file where you can add configuration options common to all sub-projects/modules.
(buildscript and dependencies)
(allprojects with repositories)

Content of app/build.gradle:

(application config section)
(dependencies section)
(Notification code) 

I am looking for assistance in resolving this issue. Can anyone help me with this?

Answer №1

Eliminate the following section from the AndroidManifest.xml file

<service android:name="io.invertase.firebase.messaging.RNFirebaseMessagingService">
        <intent-filter>
            <action android:name="com.google.firebase.MESSAGING_EVENT" />
        </intent-filter>
    </service>
 <service android:name="io.invertase.firebase.messaging.RNFirebaseInstanceIdService">
        <intent-filter>
            <action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
        </intent-filter>
    </service> 

Answer №2

To easily resolve the issue, simply delete the unnecessary services from the AndroidManifest.xml without altering the event intents.

Answer №3

It turns out that Mike Hardy was correct.

The reason I encountered this issue was due to my reliance on outdated tutorials.

By removing the mistakenly added services listed below, the problem was successfully resolved:

  <!-- [START firebase_service] -->
  <service
    android:name=".java.MyFirebaseMessagingService"
    android:exported="false">
    <intent-filter>
      <action android:name="com.google.firebase.MESSAGING_EVENT" />
    </intent-filter>
  </service>
  <!-- [END firebase_service] -->

I trust that this information will be beneficial to others :)

Answer №4

 <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.VIBRATE" />  
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />  
    <uses-permission android:name="android.permission.WAKE_LOCK"/>
    <uses-permission android:name="com.sec.android.provider.badge.permission.WRITE" tools:node="remove" />
    <uses-permission android:name="com.oppo.launcher.permission.WRITE_SETTINGS"  tools:node="remove"/>
    <uses-permission android:name="com.huawei.android.launcher.permission.WRITE_SETTINGS" tools:node="remove" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>


<application>
<meta-data  android:name="com.dieam.reactnativepushnotification.notification_channel_name"
                android:value="YOUR NOTIFICATION CHANNEL NAME"/>
        <meta-data  android:name="com.dieam.reactnativepushnotification.notification_channel_description"
                    android:value="YOUR NOTIFICATION CHANNEL DESCRIPTION"/>
        <!-- Set this value to true for popup on receiving remote notifications while in foreground, and false to prevent duplication with local notifications -->
        <meta-data  android:name="com.dieam.reactnativepushnotification.notification_foreground"
                    android:value="false"/>
        
        <meta-data  android:name="com.dieam.reactnativepushnotification.notification_color"
                    android:resource="@color/white"/> 

        <receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationActions" />
        <receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationPublisher" />
        <receiver android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationBootEventReceiver">
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED" />
                <action android:name="android.intent.action.QUICKBOOT_POWERON" />
                <action android:name="com.htc.intent.action.QUICKBOOT_POWERON"/>
            </intent-filter>
        </receiver>

        <service
            android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationListenerService"
            android:exported="false" >
            <intent-filter>
                <action android:name="com.google.firebase.MESSAGING_EVENT" />
            </intent-filter>
        </service>
<application>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

An easy way to enable mobility for BootstrapDialog on mobile devices

Currently, I am utilizing the library available at https://github.com/nakupanda/bootstrap3-dialog in order to create a dialog box. However, my issue arises when viewing the dialog on mobile devices where it exceeds the screen size. On desktops, adjusting t ...

Webpack encounters an error while attempting to load Bootstrap v4.0.0-beta

I've encountered an issue with my webpack configuration and Bootstrap v4.0.0-alpha.6 that was working fine until I attempted to switch to v4 beta. Unfortunately, I can't seem to get it working properly now :( Here is a snippet of my config: w ...

Tips for executing parallax designs, similar to the techniques used on the

Currently, I am in the process of creating a website that utilizes parallax scrolling. Here is a brief overview of what I have accomplished thus far. I decided to use the skrollr plugin to achieve the desired parallax effect. Through this plugin, I was abl ...

The arrow function in Jest is missing a name property

Currently, my setup includes: node.js: 9.8.0 Jest: 23.4.2 ts-jest: 23.1.3 typescript: 2.9.2 While attempting the following in my *.test.ts files: const foo = () => 'bar'; console.log(foo.name); // '' foo contains the name pro ...

Conceal the div element when located beneath an ordered list with a designated

I need help hiding the display of comment information if it is a child comment. Below is my attempt to hide the div with the id "info" if the "ol" element has a class of "children". If you have another method for hiding the div when the comment is a chil ...

What could be the reason for the malfunctioning of the Angular options tracking by ID feature?

I seem to be facing an issue with my code: There is an object that holds the id of an item, along with an array containing these items. I require a 'select' element to display the currently selected item and allow for changing the selection. Th ...

When I click on a different area, I must rotate the arrow by 180 degrees

I am working on a project where I have implemented a select menu with an arrow that rotates 180 degrees when the menu opens. However, I need to rotate it back when clicking on another area. Below is the HTML code: `<div> <select name="sele ...

Having trouble getting Angular Filter to work within a directive expression?

I am currently working on a directive where I need to convert both the attribute and object name values to lowercase. I have tried using filters, as well as the $filter service, but it doesn't seem to be working. Can anyone please provide assistance i ...

Tips for properly setting and accessing data objects in React when utilizing a Firebase database

I’m encountering issues with storing and retrieving data using the useState hook in React after fetching it from a Firebase database. The issue appears to be related to not all users having all values in the playerData data packet – for example, if a p ...

Numerous Bourbon Refill Opportunities

I'm currently working on a project that involves using the Bourbon Refills UI elements and I have a particular query related to modals. Specifically, I need to have multiple modals open simultaneously in a certain scenario. Here's what I'm ...

struggling to develop a sophisticated 'shopping cart organization' program

I am in the process of creating a database for video spots, where users can view and modify a list of spots. I am currently working on implementing a cart system that automatically stores checked spot IDs as cookies, allowing users to browse multiple pages ...

Date selection feature in Material UI causing application malfunction when using defaultValue attribute with Typescript

Recently, I discovered the amazing functionality of the Material UI library and decided to try out their date pickers. Everything seemed fine at first, but now I'm facing an issue that has left me puzzled. Below is a snippet of my code (which closely ...

Is it possible for a Simplemodal popup to appear only once per user session

I'm completely new to javascript and jQuery. Recently, I've started using SimpleModal basic from SimpleModal to show a popup upon visitors landing on my website. Everything seems to be working perfectly, but there's one issue - the popup kee ...

Creating an entity using various asynchronous sources in node.js/express.js

Struggling to find a solution to my problem online and hoping someone here can help. My express route is making multiple API requests for different JSON objects, but I'm having trouble building a single JSON response for the client side view. All my a ...

What is the preferred approach in JavaScript: having a single large file or multiple smaller files?

Having a multitude of JavaScript files loaded on a single page can result in decreased performance. My inquiry is this: Is it preferable to have individual files or combine them into one JavaScript file? If consolidating all scripts into one file is the ...

Error message displaying that the argument for the onChange state in a jhipster react form is not assignable as type '{ [x: number]: any; }'

Just diving into the world of React and encountering a bit of a struggle with jsx when it comes to setting state in a form that contains two fields and triggers an ajax call to store a json object (response data) in the state's field3. The code I curr ...

Ways to enlarge the parent container and reveal a concealed child element upon hovering without impacting neighboring containers

Currently, I am diligently working on the company service boxes and have a particular need... When hovering over: 1. The parent div should scale up and acquire box shadow without impacting the neighboring service boxes (it should appear to stand out above ...

Swapping Out Models in Three.js: A Guide to Replacing Object3D Models

I'm attempting to swap out an object3D for a character model, while retaining all of its attributes like the position. var object = new THREE.Object3D( ); object = models.character[0].clone( ); object.position.set( 100, 230, 15 ); scene.add( object.sc ...

Empty array returned when using fetch in a for loop

Currently, I am developing a server route to execute API calls. I have encountered the need to make two separate fetch requests as I require additional information that is not available in the first fetch. The issue lies in declaring a variable outside o ...

Tips for triggering the .click() function upon returning to index.html after visiting a different page

I'm in the process of creating a portfolio website where the index.html page features a sliding navigation bar that displays a collection of projects. Each project is linked to a separate work.html page. I would like the sliding nav to automatically o ...