java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/firebase/iid/FirebaseInstanceId; React Native App

Viewed 4723

I've been trying to run my react native application, but it crashed when started and the debugger didn't return any error, so I checked the log cat in Android Studio and it shows me the following error: java.lang.NoClassDefFoundError: Failed resolution of: Lcom / google / firebase / iid / FirebaseInstanceId;

Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.firebase.iid.FirebaseInstanceId"

The React-Native version that I am using is: 0.61.5 And the version of react-native-firebase that I have installed is 5.6.0

It has already been a recent failure, since previously the app worked correctly and I have not made any changes to the firebase integration either

4 Answers

To debug this, first I would suggest running adb logcat and seeing what Java error you are getting. If it errors out on the not being able to find the required Java classes, then try adding the following to your project:

app/build.gradle file (dependencies section):

implementation 'com.google.firebase:firebase-iid'

(You might need to provide a version for this package as well)

I have getting same error, I fixed this error by uninstalling old version and installing new version of push notification.

uninstall:
npm uninstall react-native-push-notification
install:
npm i react-native-push-notification

since react-native-push-notification upgraded to new version v7.x so that, while installing app it give above error.

checkout this -> https://www.npmjs.com/package/react-native-push-notification

There is an issue, in react-native-push-notification (FirebaseInstanceId has been deprecated and now removed). Sounds like you are using a lib that is using that that here. It should be fixed later on, but for now you can add the following to your android/build.gradel file.

buildscript {
    ext {
        ...
        firebaseMessagingVersion = "21.0.0"
    }

I had also to update these libs (you will get compile errors if you don't, so you may have others to update):

-    "react-native-device-info": "^5.5.8",
+    "react-native-device-info": "^8.1.3",

-    "react-native-push-notification": "^7.3.0",
+    "react-native-push-notification": "^7.3.1",

This is in reference to this issue

wix/react-native-notifications This lib having issue with refreshToken() Method.

Didn't find class "com.google.firebase.iid.FirebaseInstanceId"

so just remove / reinstall the package, if still error is coming then we have to wait for next bug fix release of this lib or

we can manually change native code to make it working.

below is link of lib

https://github.com/wix/react-native-notifications/issues?q=FirebaseInstanceId

Related