JAVA_HOME 未设置错误,运行 React-native 应用程序后 [英] JAVA_HOME is not set error, after running React-native app
问题描述
PS C:\Users\Prabhudev\react-projects\react-native\myFirstApp> react-native run-android
PS C:\Users\Prabhudev\react-projects\react-native\myFirstApp> react-native run-android
信息 JS 服务器已在运行.info 在设备上构建和安装应用程序 (cd android && gradlew.bat app:installDebug)...
info JS server already running. info Building and installing the app on the device (cd android && gradlew.bat app:installDebug)...
错误:未设置 JAVA_HOME 并且在您的路径中找不到java"命令.
请在您的环境中设置 JAVA_HOME 变量以匹配您的 Java 安装位置.
ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the location of your Java installation.
错误无法在设备上安装应用程序,请阅读上面的错误了解详情.确保您有一个正在运行的 Android 模拟器或已连接的设备设置您的 Android 开发环境:
error Could not install the app on the device, read the error above for details. Make sure you have an Android emulator running or a device connected and have set up your Android development environment:
https://facebook.github.io/react-native/docs/getting-started.html
错误命令失败:gradlew.bat app:installDebug.使用 --verbose 标志运行 CLI 以获取更多详细信息.
error Command failed: gradlew.bat app:installDebug. Run CLI with --verbose flag for more details.
推荐答案
首先将 JDK 和 JRE 路径添加到系统变量Path"像下面这样:
First Add the JDK and JRE paths to the System Variable "Path" like below:
其次,将 JAVA JDK 路径添加到 USER 变量中作为 JAVA_HOME.如下所示:
Secondly, Add the JAVA JDK path to the USER variable as JAVA_HOME. as shown below:
重启cmd进入app目录,用react-native run-android运行app瞧:
Restart the cmd and go to the app directory and run the app with react-native run-android Voila:
这篇关于JAVA_HOME 未设置错误,运行 React-native 应用程序后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!