How to slove this issue - Task :react-native-push-notification:compileDebugJavaWithJavac FAILED , import com.google.firebase.iid issue

Viewed 7597

enter image description here![\node_modules\react-native-push-notification\android\src\main\java\com\dieam\reactnativepushnotification\modules\RNPushNotification.java:40: error: cannot find symbol

import com.google.firebase.iid.InstanceIdResult

6 Answers

There is some issue at 7.2.* version. Try moving to the latest version or any 7.3.* version.

npm i react-native-push-notification@latest

I faced this issue yesterday. And I fixed it by using the following steps.

First I uninstalled it.

npm uninstall react-native-push-notification

Then I installed it back in. (Maybe you can just update it to the latest version as well. I just didn't know the npm command line for that)

npm install react-native-push-notification

In android/app/build.gradle, add the following code in defaultConfig :

dexOptions {
            javaMaxHeapSize "4g"
        }

Also add: implementation 'com.google.firebase:firebase-messaging:21.1.0'

In android/gradle.properties, add the following code:

firebaseMessagingVersion=21.1.0

Delete node_module. (Perhaps, you don't need to do this.)

Finally, run npm install. You might have to run yarn install and rebuild your project again with Android Studio as well.

You probably don't need to follow every step in here. But these are what I did yesterday. I hope this helps.

Follow the steps.

  1. npm i react-native-push-notification@latest

  2. android/build.gradle

     buildscript {
    ext {
         //  ...
        firebaseMessagingVersion = '21.1.0'
    }
    

    }

These steps are worked for me.

try with updating the npm package.

  • "react-native-push-notification": "^7.3.0"

by cleaning the cache also

  • cd android && ./gradlew clean

I update these tow files:

package.json :

"react-native-push-notification": "^7.2.2" to "react-native-push-notification": "^7.3.0"

android\app\build.gradle :

implementation 'com.google.firebase:firebase-analytics:17.3.0' to implementation 'com.google.firebase:firebase-analytics:19.0.0'

and its worked!

Related