react-native-push-notification 无法在 android 中构建 [英] react-native-push-notification can not build in android

查看:63
本文介绍了react-native-push-notification 无法在 android 中构建的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将在我的应用程序中使用 react-native-push-notification 作为通知,但是当我使用这个库时,它给了我这样的错误......

I'll be using react-native-push-notification for notifications in my app but when I use this library it gives me error like this.....

> 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

推荐答案

尝试在react-native-push-notification/android/build.gradle上升级这个依赖

Try to upgrade on react-native-push-notification/android/build.gradle this dependencies

  • 定义 DEFAULT_COMPILE_SDK_VERSION = 26
  • def DEFAULT_BUILD_TOOLS_VERSION = "26.1.0"
  • 定义 DEFAULT_TARGET_SDK_VERSION = 23
  • def DEFAULT_SUPPORT_LIB_VERSION = "26.1.0"
  • def DEFAULT_GOOGLE_PLAY_SERVICES_VERSION = "+"
  • def DEFAULT_FIREBASE_MESSAGING_VERSION = "+"

如果这对您有帮助,请告诉我

let me know if that helps you

RNPushNotifications android 出错

这篇关于react-native-push-notification 无法在 android 中构建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆