我将在我的应用程序中使用react-native-push-notification进行通知,但是当我使用此库时,它给我这样的错误.....
> Task :react-native-push-notification:compileDebugJavaWithJavac FAILED
E:\AndroidNotify\node_modules\react-native-push-notification\android\src\main\java\com\dieam\reactnativepushnotification\modules\RNPushNotificationHelper.java:7: error: cannot find symbol
import android.app.NotificationChannel;
^
symbol: class NotificationChannel
location: package android.app
E:\AndroidNotify\node_modules\react-native-push-notification\android\src\main\java\com\dieam\reactnativepushnotification\modules\RNPushNotificationHelper.java:480: error: cannot find symbol
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O)
^
symbol: variable O
location: class VERSION_CODES
E:\AndroidNotify\node_modules\react-native-push-notification\android\src\main\java\com\dieam\reactnativepushnotification\modules\RNPushNotificationHelper.java:488: error: cannot find symbol
int importance = NotificationManager.IMPORTANCE_DEFAULT;
^
symbol: variable IMPORTANCE_DEFAULT
location: class NotificationManager
E:\AndroidNotify\node_modules\react-native-push-notification\android\src\main\java\com\dieam\reactnativepushnotification\modules\RNPushNotificationHelper.java:489: error: cannot find symbol
NotificationChannel channel = new NotificationChannel(NOTIFICATION_CHANNEL_ID, name, importance);
^
symbol: class NotificationChannel
location: class RNPushNotificationHelper
E:\AndroidNotify\node_modules\react-native-push-notification\android\src\main\java\com\dieam\reactnativepushnotification\modules\RNPushNotificationHelper.java:489: error: cannot find symbol
NotificationChannel channel = new NotificationChannel(NOTIFICATION_CHANNEL_ID, name, importance);
^
symbol: class NotificationChannel
location: class RNPushNotificationHelper
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
5 errors
答案 0 :(得分:3)
尝试在react-native-push-notification / android / build.gradle上升级此依赖项
让我知道这是否对您有帮助
答案 1 :(得分:0)
在将deprecated 'compile' issue
固定为dependency configurations - module's build.gradle
之后,我也遇到了这个问题,但是我没有在那里更改SDK versions
,而是添加了{{1 }}在API Level 28
中的SDK Platforms
上,并且...voilà。
答案 2 :(得分:0)
增加complieSDK> = 26(奥利奥)。 通知频道是在Oreo或SDK 26中引入的