当我试图编译我的android React原生应用程序时,我得到了下面的错误。
: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。我还没有看到任何其他可能导致这个问题的建议。
发布于 2018-08-08 13:47:52
安卓/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 = 27def DEFAULT_BUILD_TOOLS_VERSION = "27.0.3“
默认DEFAULT_TARGET_SDK_VERSION = 26
26.+ DEFAULT_SUPPORT_LIB_VERSION =“def”
def DEFAULT_GOOGLE_PLAY_SERVICES_VERSION = "+“
def DEFAULT_FIREBASE_MESSAGING_VERSION = "+“
https://stackoverflow.com/questions/51738289
复制相似问题