【问题标题】:react-native-push-notification issue on building app构建应用程序的本机推送通知问题
【发布时间】:2021-05-12 09:48:39
【问题描述】:

谁能帮助我。我现在正在开发一个应用程序,它可以在我的几个小时内运行,但现在我收到一条错误消息。 我还尝试在不同版本上更新 EXT{}

"react": "16.13.1",
"react-native": "0.63.2",
 "react-native-push-notification": "^7.2.3",
        ext {
                   googlePlayServicesVersion = "+" // default: "+"
                firebaseMessagingVersion = "+" // default: "+"
                buildToolsVersion = "28.0.3"
                minSdkVersion = 16
                compileSdkVersion = 29
                targetSdkVersion = 29
                 supportLibVersion = "23.1.1"
            }
     dependencies {
            classpath("com.android.tools.build:gradle:3.5.3")
            // NOTE: Do not place your application dependencies here; they belong
            // in the individual module build.gradle files
        }

我试过了

  1. ./gradlew assembleRelease --warning-mode all
  2. ./gradlew :app:bundleRelease
  3. ./gradlew clean
  4. 同时删除 node_modules 并再次安装

但还是一样

这是错误:

> Task :react-native-push-notification:compileDebugJavaWithJavac FAILED

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.7/userguide/command_line_interface.html#sec:command_line_warnings
118 actionable tasks: 109 executed, 9 up-to-date
Note: C:\Users\SBPC\offline_hotel\new\staff\realm-tutorial-react-native\node_modules\@react-native-picker\picker\android\src\main\java\com\reactnativecommunity\picker\ReactPickerManager.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: C:\Users\SBPC\offline_hotel\new\staff\realm-tutorial-react-native\node_modules\react-native-bluetooth-escpos-printer\android\src\main\java\cn\jystudio\bluetooth\tsc\TscCommand.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: [2] Wrote GeneratedAppGlideModule with: [com.bumptech.glide.integration.okhttp3.OkHttpLibraryGlideModule, com.dylanvann.fastimage.FastImageOkHttpProgressGlideModule]
Note: C:\Users\SBPC\offline_hotel\new\staff\realm-tutorial-react-native\node_modules\react-native-fs\android\src\main\java\com\rnfs\RNFSManager.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
C:\Users\SBPC\offline_hotel\new\staff\realm-tutorial-react-native\node_modules\react-native-push-notification\android\src\main\java\com\dieam\reactnativepushnotification\modules\RNPushNotification.java:39: error: cannot find symbol
import com.google.firebase.iid.FirebaseInstanceId;
                              ^
  symbol:   class FirebaseInstanceId
  location: package com.google.firebase.iid
C:\Users\SBPC\offline_hotel\new\staff\realm-tutorial-react-native\node_modules\react-native-push-notification\android\src\main\java\com\dieam\reactnativepushnotification\modules\RNPushNotification.java:40: error: cannot find symbol
import com.google.firebase.iid.InstanceIdResult;
                              ^
  symbol:   class InstanceIdResult
  location: package com.google.firebase.iid
C:\Users\SBPC\offline_hotel\new\staff\realm-tutorial-react-native\node_modules\react-native-push-notification\android\src\main\java\com\dieam\reactnativepushnotification\modules\RNPushNotification.java:143: error: cannot find symbol
              .addOnCompleteListener(new OnCompleteListener<InstanceIdResult>() {
                                                            ^
  symbol:   class InstanceIdResult
  location: class RNPushNotification
C:\Users\SBPC\offline_hotel\new\staff\realm-tutorial-react-native\node_modules\react-native-push-notification\android\src\main\java\com\dieam\reactnativepushnotification\modules\RNPushNotification.java:145: error: cannot find symbol
                  public void onComplete(@NonNull Task<InstanceIdResult> task) {
                                                       ^
  symbol: class InstanceIdResult
C:\Users\SBPC\offline_hotel\new\staff\realm-tutorial-react-native\node_modules\react-native-push-notification\android\src\main\java\com\dieam\reactnativepushnotification\modules\RNPushNotification.java:142: error: cannot find symbol
      FirebaseInstanceId.getInstance().getInstanceId()
      ^
  symbol:   variable FirebaseInstanceId
  location: class RNPushNotification
C:\Users\SBPC\offline_hotel\new\staff\realm-tutorial-react-native\node_modules\react-native-push-notification\android\src\main\java\com\dieam\reactnativepushnotification\modules\RNPushNotification.java:289: error: cannot find symbol
                  FirebaseInstanceId.getInstance().deleteInstanceId();
                  ^
  symbol: variable FirebaseInstanceId
Note: C:\Users\SBPC\offline_hotel\new\staff\realm-tutorial-react-native\node_modules\react-native-push-notification\android\src\main\java\com\dieam\reactnativepushnotification\modules\RNPushNotificationHelper.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: C:\Users\SBPC\offline_hotel\new\staff\realm-tutorial-react-native\node_modules\react-native-push-notification\android\src\main\java\com\dieam\reactnativepushnotification\modules\RNPushNotification.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
6 errors

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':react-native-push-notification:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.       

* Get more help at https://help.gradle.org

BUILD FAILED in 59s

error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup. Run CLI with --verbose flag for more details.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
Note: C:\Users\SBPC\offline_hotel\new\staff\realm-tutorial-react-native\node_modules\@react-native-picker\picker\android\src\main\java\com\reactnativecommunity\picker\ReactPickerManager.java uses or overrides a deprecated API.

【问题讨论】:

    标签: react-native react-redux react-native-push-notification


    【解决方案1】:

    似乎这是最近影响很多开发人员的问题。我也面临同样的问题。以下解决方案对我有用。

    1. 将 react-native-push-notification 版本更改为 ^7.3.0。这解决了我的一个项目中的构建问题。

    1. 进行下面提到的更改。

    在 android/app/build.gradle 中,将以下代码添加到依赖项中:

    implementation 'com.google.firebase:firebase-messaging:21.1.0'

    在 android/build.gradle 中,进行以下更改:

    buildscript {
      ext {
        buildToolsVersion = "28.0.3"
        ...rest of your code
      }
      ...rest of your code
    }
    

    这在另一个项目中也对我有用。试一试,如果其中任何一个对您有用,请提及!

    【讨论】:

    • 谢谢第一个选项对我有用。非常感谢!
    • 很高兴听到这个消息。继续编码,继续帮助他人
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-10-10
    • 2017-11-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多