gpt4 book ai didi

android - 导入 android.app.NotificationChannel 错误

转载 作者:行者123 更新时间:2023-11-29 23:42:39 27 4
gpt4 key购买 nike

我在尝试编译我的 android React-native 应用程序时遇到以下错误。

    :react-native-push-notification:compileReleaseJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.).
/tmp/workspace/my-develop/my_app/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
/tmp/workspace/my-develop/my_app/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
/tmp/workspace/my-develop/my_app/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
/tmp/workspace/my-develop/my_app/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
/tmp/workspace/my-develop/my_app/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: /tmp/workspace/my-develop/my_app/node_modules/react-native-push-notification/android/src/main/java/com/dieam/reactnativepushnotification/helpers/ApplicationBadgeHelper.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
5 errors
:react-native-push-notification:compileReleaseJavaWithJavac FAILED

我看过很多帖子说这个问题可以通过设置compileSdkVersion 26来解决。但是我已经将此设置为 26。对于可能导致此问题的原因,我还没有看到任何其他建议。

最佳答案

android/build.gradle:

dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
}

android/app/build.gradle:

compileSdkVersion 26
buildToolsVersion "26.0.2"
...
defaultConfig {
...
minSdkVersion 16
targetSdkVersion 22
...
}

在 react-native-push-notification/android/build.gradle 中

 dependencies {
classpath 'com.android.tools.build:gradle:2.2.3' //-----> Changed this from 2.1.3

def DEFAULT_COMPILE_SDK_VERSION = 27

def DEFAULT_BUILD_TOOLS_VERSION = "27.0.3"

def DEFAULT_TARGET_SDK_VERSION = 26

def DEFAULT_SUPPORT_LIB_VERSION = "26.+"

def DEFAULT_GOOGLE_PLAY_SERVICES_VERSION = "+"

def DEFAULT_FIREBASE_MESSAGING_VERSION = "+"

关于android - 导入 android.app.NotificationChannel 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51738289/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com