>任务:@react-native-firebase_messaging:编译调试JavaWithJavac失败

p8ekf7hl  于 2022-11-17  发布在  React
关注(0)|答案(3)|浏览(150)

当我尝试使用这些命令yarn run androidreact-native run-android构建Android时,我显示了这个错误。请帮助mw解决这个错误。
下面是package.json

"@react-native-firebase/admob": "^11.5.0",
    "@react-native-firebase/app": "^11.5.0",
    "@react-native-firebase/messaging": "^11.5.0",

错误:

> Configure project :react-native-firebase_messaging
:react-native-firebase_messaging package.json found at /Users/apple/Desktop/xnd-react-native/node_modules/@react-native-firebase/messaging/package.json
:@react-native-firebase_app package.json found at /Users/apple/Desktop/xnd-react-native/node_modules/@react-native-firebase/app/package.json
:react-native-firebase_messaging:firebase.bom using default value: 26.8.0
:react-native-firebase_messaging package.json found at /Users/apple/Desktop/xnd-react-native/node_modules/@react-native-firebase/messaging/package.json
:react-native-firebase_messaging:version set from package.json: 11.5.0 (11,5,0 - 11005000)
:react-native-firebase_messaging:android.compileSdk using custom value: 31
:react-native-firebase_messaging:android.targetSdk using custom value: 31
:react-native-firebase_messaging:android.minSdk using custom value: 21
:react-native-firebase_messaging:reactNativeAndroidDir /Users/apple/Desktop/xnd-react-native/node_modules/react-native/android

> Task :@react-native-firebase_messaging: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.5/userguide/command_line_interface.html#sec:command_line_warnings
17 actionable tasks: 1 executed, 16 up-to-date
aij0ehis

aij0ehis1#

我在jdk 8中也有同样的问题。当我将jdk 8更改为11时,它对我有效。
要从jdk 8更新到11,请访问https://github.com/invertase/react-native-firebase/issues/1988#issuecomment-1070831039

axr492tv

axr492tv2#

更新JDK版本并尝试,
可以使用以下命令更新JDK

choco install -y nodejs-lts openjdk11
bkhjykvo

bkhjykvo3#

当我从JDK 8切换到11时,它解决了这个问题。
按照说明进行切换
1.打开新的“终端”窗口并输入:

/usr/libexec/java_home -V

1.它可能如下所示:

Matching Java Virtual Machines (2):

11.0.17 (arm64) "Oracle Corporation" - "Java SE 11.0.17" 
/Library/Java/JavaVirtualMachines/jdk- 
11.0.17.jdk/Contents/Home

1.8.0_292 (x86_64) "AdoptOpenJDK" - "AdoptOpenJDK 8" 
/Library/Java/JavaVirtualMachines/adoptopenjdk- 
8.jdk/Contents/Home
/Library/Java/JavaVirtualMachines/jdk- 
11.0.17.jdk/Contents/Home

您可能只看到一个版本,可能是1.8(JDK 8),如果是这样,请转到https://www.oracle.com/java/technologies/downloads/下载JDK 11。
1.成功下载并安装后,您将运行此命令以切换。

export JAVA_HOME=`/usr/libexec/java_home -v 1.8`

1.在终端中检查JDK版本:

java --version

您也可以查看下面的链接
https://medium.com/@devkosal/switching-java-jdk-versions-on-macos-80bc868e686a

相关问题