运行react native 报错,java_home 的问题
**ERROR: JAVA_HOME is set to an invalid directory: D:\vscode\JDK11\bin**
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.
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
at makeError (D:\vscode\React-Native\MyProject\node_modules\@react-native-community\cli-platform-android\node_modules\execa\index.js:174:9)
at D:\vscode\React-Native\MyProject\node_modules\@react-native-community\cli-platform-android\node_modules\execa\index.js:278:16
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async runOnAllDevices (D:\vscode\React-Native\MyProject\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:109:5)
at async Command.handleAction (D:\vscode\React-Native\MyProject\node_modules\@react-native-community\cli\build\index.js:192:9)
info Run CLI with --verbose flag for more details.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
**ERROR: JAVA_HOME is set to an invalid directory: D:\vscode\JDK11\bin**
根据这个错误来看,是你设置的这个路径无效。
正常情况下设置
C:\Program Files\Java\jdk1.8.0_152\bin
你先看看D:\vscode\JDK11\bin这个路径是否存在,路径下是否有java.exe,jdk是否完整
在Path环境变量里面修改下java_home对应的路径就好了啊
感谢邀请
JAVA_HOME环境变量设置的有问题
可以对照这篇文章,看下你的设置哪块不合适:Java配置环境变量 - jialin丶snake - 博客园
题主rn什么版本尼,0.69才支持jdk11。
看log环境变量有问题尼,配置玩之后记得重启as。
虚拟机不是必须的,可以用真机