我将在我的应用程序中使用react-native-push通知,但是当我使用这个库时,它会给我这样的错误.
> 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
发布于 2018-08-04 12:50:45
尝试在react-native-push-notification/android/build.gradle此依赖项上升级
H19定义DEFAULT_GOOGLE_PLAY_SERVICES_VERSION =“+”H210H111def DEFAULT_FIREBASE_MESSAGING_VERSION =“+”H212F213
如果这对你有帮助,请告诉我
发布于 2018-11-04 05:52:05
我也遇到过这个问题,但是在修复了dependency configurations - module's build.gradle中的deprecated 'compile' issue之后,我并没有在那里更改SDK versions,而是在Android Studio中的SDK Platforms上添加了API Level 28……瞧啊。
发布于 2018-12-14 21:41:21
增加complieSDK >= 26 (奥利奥)。通知通道是在Oreo或SDK 26中引入的
https://stackoverflow.com/questions/51682448
复制相似问题