对构建应用程序上的本地推送通知问题作出反应



有人能帮我吗?我现在正在开发一个应用程序,它能在我的几个小时内工作,但现在我收到了一条错误消息。我还尝试在不同版本的上更新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 assemblyRelease—警告模式全部
  2. /gradlew:app:bundleRelease
  3. /gradlew清洁
  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:UsersSBPCoffline_hotelnewstaffrealm-tutorial-react-nativenode_modules@react-native-pickerpickerandroidsrcmainjavacomreactnativecommunitypickerReactPickerManager.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:UsersSBPCoffline_hotelnewstaffrealm-tutorial-react-nativenode_modulesreact-native-bluetooth-escpos-printerandroidsrcmainjavacnjystudiobluetoothtscTscCommand.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:UsersSBPCoffline_hotelnewstaffrealm-tutorial-react-nativenode_modulesreact-native-fsandroidsrcmainjavacomrnfsRNFSManager.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:UsersSBPCoffline_hotelnewstaffrealm-tutorial-react-nativenode_modulesreact-native-push-notificationandroidsrcmainjavacomdieamreactnativepushnotificationmodulesRNPushNotification.java:39: error: cannot find symbol
import com.google.firebase.iid.FirebaseInstanceId;
^
symbol:   class FirebaseInstanceId
location: package com.google.firebase.iid
C:UsersSBPCoffline_hotelnewstaffrealm-tutorial-react-nativenode_modulesreact-native-push-notificationandroidsrcmainjavacomdieamreactnativepushnotificationmodulesRNPushNotification.java:40: error: cannot find symbol
import com.google.firebase.iid.InstanceIdResult;
^
symbol:   class InstanceIdResult
location: package com.google.firebase.iid
C:UsersSBPCoffline_hotelnewstaffrealm-tutorial-react-nativenode_modulesreact-native-push-notificationandroidsrcmainjavacomdieamreactnativepushnotificationmodulesRNPushNotification.java:143: error: cannot find symbol
.addOnCompleteListener(new OnCompleteListener<InstanceIdResult>() {
^
symbol:   class InstanceIdResult
location: class RNPushNotification
C:UsersSBPCoffline_hotelnewstaffrealm-tutorial-react-nativenode_modulesreact-native-push-notificationandroidsrcmainjavacomdieamreactnativepushnotificationmodulesRNPushNotification.java:145: error: cannot find symbol
public void onComplete(@NonNull Task<InstanceIdResult> task) {
^
symbol: class InstanceIdResult
C:UsersSBPCoffline_hotelnewstaffrealm-tutorial-react-nativenode_modulesreact-native-push-notificationandroidsrcmainjavacomdieamreactnativepushnotificationmodulesRNPushNotification.java:142: error: cannot find symbol
FirebaseInstanceId.getInstance().getInstanceId()
^
symbol:   variable FirebaseInstanceId
location: class RNPushNotification
C:UsersSBPCoffline_hotelnewstaffrealm-tutorial-react-nativenode_modulesreact-native-push-notificationandroidsrcmainjavacomdieamreactnativepushnotificationmodulesRNPushNotification.java:289: error: cannot find symbol
FirebaseInstanceId.getInstance().deleteInstanceId();
^
symbol: variable FirebaseInstanceId
Note: C:UsersSBPCoffline_hotelnewstaffrealm-tutorial-react-nativenode_modulesreact-native-push-notificationandroidsrcmainjavacomdieamreactnativepushnotificationmodulesRNPushNotificationHelper.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: C:UsersSBPCoffline_hotelnewstaffrealm-tutorial-react-nativenode_modulesreact-native-push-notificationandroidsrcmainjavacomdieamreactnativepushnotificationmodulesRNPushNotification.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:UsersSBPCoffline_hotelnewstaffrealm-tutorial-react-nativenode_modules@react-native-pickerpickerandroidsrcmainjavacomreactnativecommunitypickerReactPickerManager.java uses or overrides a deprecated API.

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

  1. 将react原生推送通知版本更改为^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
}

这在另一个项目中也对我起到了作用。试试看,如果其中任何一个对你有用,请提及!

最新更新