java - JAVA 错误:React 本机基本项目在 android studio 中不起作用
问题描述
我按照本文档中的所有步骤在 android studio 中安装和运行 react native 项目。
当我在模拟器中运行命令npx react-native run-android
以运行项目时,终端出现以下错误。
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 901 file(s) to forward-jetify. Using 8 workers...
info JS server already running.
info Installing the app...
> Task :app:processDebugMainManifest FAILED
11 actionable tasks: 11 executed
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 @6353fde6
* 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 16s
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 app:installDebug -PreactNativeDevServerPort=8081
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 @6353fde6
* 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 16s
at makeError (/var/www/html/test_native/node_modules/execa/index.js:174:9)
at /var/www/html/test_native/node_modules/execa/index.js:278:16
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at async runOnAllDevices (/var/www/html/test_native/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:94:5)
at async Command.handleAction (/var/www/html/test_native/node_modules/react-native/node_modules/@react-native-community/cli/build/index.js:186:9)
info Run CLI with --verbose flag for more details.
环境:
Ubuntu 16.04
Node 14.15.4
Java 16
Latest Android Studio
环境变量:
JAVA_HOME="/usr/lib/jvm/jdk-16"
ANDROID_SDK_ROOT="/home/dev-21/Android/Sdk"
ANDROID_HOME="/home/dev-21/Android/Sdk"
解决方案
今天有同样的问题,对我有用的是降级到 java 14,基于这个建议:https ://stackoverflow.com/a/66951023/1021253
推荐阅读
- database - Neo4j - 如何在全文搜索中使用 createRelationshipIndex / createNodeIndex
- oracle - 查找所有表中可用字段的最大值
- azure - 创建 VM、对其进行映像然后将其删除后可用的 vCPU 配额不足
- javascript - 使用 php 将 blob 音频文件上传到 aws ec2-instance
- javascript - 函数 createEvent 返回 null
- ios - 如何使用 Transporter 将 ipa 文件加载到应用商店?“构建”为空
- c++ - C++ 到 VB.NET 的转换
- java - 垂直系统拥塞
- git - 从另一个人的叉子修改拉取请求
- r - 如何使用带有 dplyr 的管道将数据帧变量传递给 for 循环?