所以我在android上启动初始react-native模板项目时遇到了一些问题。在咨询某人后,我被告知jdk 17不支持。但我真的不想降级,因为这可能会破坏我已经使用的其他东西。具体来说,这是我得到的错误:
> Task :app:processDebugMainManifest FAILED
11 actionable tasks: 2 executed, 9 up-to-date
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:processDebugMainManifest'.
> Unable to make field private final java.lang.String java.io.File.path accessible: module java.base does not "opens java.io" to unnamed module @7ec6bc9b
* 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 20s
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
* What went wrong:
Execution failed for task ':app:processDebugMainManifest'.
> Unable to make field private final java.lang.String java.io.File.path accessible: module java.base does not "opens java.io" to unnamed module @7ec6bc9b
* 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 20s
at makeError (C:\Users\karti\Desktop\ShoppingList\node_modules\execa\index.js:174:9)
at C:\Users\karti\Desktop\ShoppingList\node_modules\execa\index.js:278:16
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async runOnAllDevices (C:\Users\karti\Desktop\ShoppingList\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid at async Command.handleAction (C:\Users\karti\Desktop\ShoppingList\node_modules\@react-native-community\cli\build\index.js:192:9)
字符串
我已经看过这个了,没有任何效果。Gradle: Execution failed for task ':processDebugManifest'
3条答案
按热度按时间mfuanj7w1#
要知道这是否是Java版本相关的问题,您需要检查您的Gradle版本。
目前只有Gradle 7.3版本支持Java 17。
你可以检查gradle compatibility matrix来检查。
你可以用命令行输入
gradlew.bat -version
来检查你的版本如果你的Gradle是7.3版本,那么它与JDK版本无关。
5vf7fwbs2#
所以我通过在我的系统上安装JDK 16解决了这个问题,一切都解决了,运行正常。我不知道这个问题是Gradle还是JDK还是react-native,但希望将来支持jdk 17。
如果你有同样的问题,那么你可以去:jdk 16
1)下载并安装JDK 16。
2)在系统环境变量的PATH中添加jdk的路径。
3)打开cmd并执行
java -version
,您应该看到类似于字符串
bbmckpt73#
对我来说,react native没有成功地与OpenJdk 17一起工作。
安装OpenJDK 11后,这个问题得到了解决。