Getting Error import android.support.v4.app.NotificationManagerCompat
E:\react\sutiTaskManager\node_modules\react-native-push-notification\android\src\main\java\com\dieam\reactnativepushnotification\modules\RNPushNotification.java:11: error: cannot find symbol import android.support.v4.app.NotificationManagerCompat; ^ symbol: class NotificationManagerCompat location: package android.support.v4.app E:\react\sutiTaskManager\node_modules\react-native-push-notification\android\src\main\java\com\dieam\reactnativepushnotification\modules\RNPushNotificationHelper.java:22: error: cannot find symbol import android.support.v4.app.NotificationCompat; ^ symbol: class NotificationCompat location: package android.support.v4.app E:\react\sutiTaskManager\node_modules\react-native-push-notification\android\src\main\java\com\dieam\reactnativepushnotification\modules\RNPushNotificationAttributes.java:4: error: package android.support.annotation does not exist import android.support.annotation.NonNull; ^ E:\react\sutiTaskManager\node_modules\react-native-push-notification\android\src\main\java\com\dieam\reactnativepushnotification\modules\RNPushNotificationConfig.java:6: error: package android.support.v4.content.res does not exist import android.support.v4.content.res.ResourcesCompat; ^ E:\react\sutiTaskManager\node_modules\react-native-push-notification\android\src\main\java\com\dieam\reactnativepushnotification\modules\RNPushNotificationAttributes.java:120: error: cannot find symbol @NonNull ^ symbol: class NonNull location: class RNPushNotificationAttributes E:\react\sutiTaskManager\node_modules\react-native-push-notification\android\src\main\java\com\dieam\reactnativepushnotification\modules\RNPushNotification.java:126: error: cannot find symbol NotificationManagerCompat managerCompat = NotificationManagerCompat.from(reactContext); ^ symbol: class NotificationManagerCompat location: class RNPushNotification E:\react\sutiTaskManager\node_modules\react-native-push-notification\android\src\main\java\com\dieam\reactnativepushnotification\modules\RNPushNotification.java:126: error: cannot find symbol NotificationManagerCompat managerCompat = NotificationManagerCompat.from(reactContext); ^ symbol: variable NotificationManagerCompat location: class RNPushNotification E:\react\sutiTaskManager\node_modules\react-native-push-notification\android\src\main\java\com\dieam\reactnativepushnotification\modules\RNPushNotificationHelper.java:164: error: cannot find symbol int priority = NotificationCompat.PRIORITY_HIGH; ^ symbol: variable NotificationCompat location: class RNPushNotificationHelper E:\react\sutiTaskManager\node_modules\react-native-push-notification\android\src\main\java\com\dieam\reactnativepushnotification\modules\RNPushNotificationHelper.java:170: error: cannot find symbol priority = NotificationCompat.PRIORITY_MAX; ^ symbol: variable NotificationCompat location: class RNPushNotificationHelper E:\react\sutiTaskManager\node_modules\react-native-push-notification\android\src\main\java\com\dieam\reactnativepushnotification\modules\RNPushNotificationHelper.java:173: error: cannot find symbol priority = NotificationCompat.PRIORITY_HIGH; ^ symbol: variable NotificationCompat location: class RNPushNotificationHelper E:\react\sutiTaskManager\node_modules\react-native-push-notification\android\src\main\java\com\dieam\reactnativepushnotification\modules\RNPushNotificationHelper.java:176: error: cannot find symbol priority = NotificationCompat.PRIORITY_LOW; ^ symbol: variable NotificationCompat location: class RNPushNotificationHelper E:\react\sutiTaskManager\node_modules\react-native-push-notification\android\src\main\java\com\dieam\reactnativepushnotification\modules\RNPushNotificationHelper.java:179: error: cannot find symbol priority = NotificationCompat.PRIORITY_MIN; ^ symbol: variable NotificationCompat location: class RNPushNotificationHelper E:\react\sutiTaskManager\node_modules\react-native-push-notification\android\src\main\java\com\dieam\reactnativepushnotification\modules\RNPushNotificationHelper.java:182: error: cannot find symbol priority = NotificationCompat.PRIORITY_DEFAULT; ^ symbol: variable NotificationCompat location: class RNPushNotificationHelper E:\react\sutiTaskManager\node_modules\react-native-push-notification\android\src\main\java\com\dieam\reactnativepushnotification\modules\RNPushNotificationHelper.java:185: error: cannot find symbol priority = NotificationCompat.PRIORITY_HIGH; ^ symbol: variable NotificationCompat location: class RNPushNotificationHelper E:\react\sutiTaskManager\node_modules\react-native-push-notification\android\src\main\java\com\dieam\reactnativepushnotification\modules\RNPushNotificationHelper.java:189: error: cannot find symbol int visibility = NotificationCompat.VISIBILITY_PRIVATE; ^ symbol: variable NotificationCompat location: class RNPushNotificationHelper E:\react\sutiTaskManager\node_modules\react-native-push-notification\android\src\main\java\com\dieam\reactnativepushnotification\modules\RNPushNotificationHelper.java:195: error: cannot find symbol visibility = NotificationCompat.VISIBILITY_PRIVATE; ^ symbol: variable NotificationCompat location: class RNPushNotificationHelper E:\react\sutiTaskManager\node_modules\react-native-push-notification\android\src\main\java\com\dieam\reactnativepushnotification\modules\RNPushNotificationHelper.java:198: error: cannot find symbol visibility = NotificationCompat.VISIBILITY_PUBLIC; ^ symbol: variable NotificationCompat location: class RNPushNotificationHelper E:\react\sutiTaskManager\node_modules\react-native-push-notification\android\src\main\java\com\dieam\reactnativepushnotification\modules\RNPushNotificationHelper.java:201: error: cannot find symbol visibility = NotificationCompat.VISIBILITY_SECRET; ^ symbol: variable NotificationCompat location: class RNPushNotificationHelper E:\react\sutiTaskManager\node_modules\react-native-push-notification\android\src\main\java\com\dieam\reactnativepushnotification\modules\RNPushNotificationHelper.java:204: error: cannot find symbol visibility = NotificationCompat.VISIBILITY_PRIVATE; ^ symbol: variable NotificationCompat location: class RNPushNotificationHelper E:\react\sutiTaskManager\node_modules\react-native-push-notification\android\src\main\java\com\dieam\reactnativepushnotification\modules\RNPushNotificationHelper.java:208: error: package NotificationCompat does not exist NotificationCompat.Builder notification = new NotificationCompat.Builder(context, NOTIFICATION_CHANNEL_ID) ^ E:\react\sutiTaskManager\node_modules\react-native-push-notification\android\src\main\java\com\dieam\reactnativepushnotification\modules\RNPushNotificationHelper.java:208: error: package NotificationCompat does not exist NotificationCompat.Builder notification = new NotificationCompat.Builder(context, NOTIFICATION_CHANNEL_ID) ^ E:\react\sutiTaskManager\node_modules\react-native-push-notification\android\src\main\java\com\dieam\reactnativepushnotification\modules\RNPushNotificationHelper.java:273: error: package NotificationCompat does not exist notification.setStyle(new NotificationCompat.BigTextStyle().bigText(bigText)); ^ E:\react\sutiTaskManager\node_modules\react-native-push-notification\android\src\main\java\com\dieam\reactnativepushnotification\modules\RNPushNotificationHelper.java:309: error: cannot find symbol notification.setCategory(NotificationCompat.CATEGORY_CALL); ^ symbol: variable NotificationCompat location: class RNPushNotificationHelper E:\react\sutiTaskManager\node_modules\react-native-push-notification\android\src\main\java\com\dieam\reactnativepushnotification\modules\RNPushNotificationConfig.java:53: error: cannot find symbol return ResourcesCompat.getColor(context.getResources(), resourceId, null); ^ symbol: variable ResourcesCompat location: class RNPushNotificationConfig Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details. 24 errors 3 warnings
Task :react-native-push-notification:compileDebugJavaWithJavac FAILED
FAILURE: Build failed with an exception.
I had same error and fixed it. open react-native-push-notification by android studio and run refactor->migrate to android X. I think it is androidx migration issue but not sure of it that this error occurs globally. https://developer.android.com/jetpack/androidx/migrate
I had same error and fixed it. open react-native-push-notification by android studio and run refactor->migrate to android X. I think it is androidx migration issue but not sure of it that this error occurs globally. https://developer.android.com/jetpack/androidx/migrate
Solved it by Implementing Following code From stackoverfllow and related issue sections
/////////// App/ build.gradle ////////////
defaultConfig { //previous code multiDexEnabled true
}
dependencies {
// implementation project(':react-native-push-notification')
implementation(project(":react-native-push-notification"), {
exclude group: "com.google.android.gms"
})
implementation "com.google.android.gms:play-services-gcm:17.0.0"
implementation 'com.android.support:multidex:1.0.3'
//remaining dependencies implementation 'androidx.core:core:1.0.1' implementation "com.facebook.react:react-native:+" // From node_modules
configurations.all {
resolutionStrategy {
force 'com.google.android.gms:play-services-gcm:16.1.0'
force 'com.google.android.gms:play-services-base:16.1.0'
force 'com.google.firebase:firebase-core:16.0.6'
force 'com.google.firebase:firebase-messaging:17.6.0'
}
}
}
thanks @sourabhchotia I didn't want to touch react-native-push-notification but couldn't find how.
in my case, without implementation 'androidx.core:core:1.0.1' worked.
follow this PR https://github.com/zo0r/react-native-push-notification/pull/1092
I had the same error. It's because of React Native >= 0.60
It uses androidx which breaks all old `android.support´ packages. Simply install this package not from npm but from Github.
I wrote a small guide here: https://dev.to/bdbch/how-to-get-react-native-push-notifications-to-work-with-react-native-0-60-e20
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 30 days if no further activity occurs. Thank you for your contributions.
run command npx jetify
run command
npx jetify
Thanks @zohaib201 It worked