代码之家  ›  专栏  ›  技术社区  ›  Magick

进口android.app.NotificationChannel错误

  •  1
  • Magick  · 技术社区  · 6 年前

    我在编译我的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 . 我还没有看到任何其他可能导致这个问题的建议。

    1 回复  |  直到 6 年前
        1
  •  1
  •   Sujatha Girijala    6 年前

    安卓/生成.gradle:

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

    android/应用程序/生成.gradle:

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

    Inside react native推送通知/android/生成.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_SUPPORT_LIB_VERSION=“26.+”

    def DEFAULT_GOOGLE_PLAY_SERVICES_VERSION=“+”

    def DEFAULT_FIREBASE_MESSAGING_VERSION=“+”