【发布时间】:2019-09-13 09:36:36
【问题描述】:
我最近在我的 Windows PC 上安装了 React Native 并创建了一个项目,但是当我尝试使用 react-native run-android for android 模拟器时,它向我显示:
C:\ReactNative\testproj>react-native run-android
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 855 file(s) to forward-jetify. Using 4 workers...
info JS server already running.
info Installing the app...
ERROR: JAVA_HOME is set to an invalid directory: C:\Program Files (x86)\Java
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://facebook.github.io/react-native/docs/getting-started.html#android-development-environment. Run CLI with --verbose flag for more details.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
at checkExecSyncError (child_process.js:629:11)
at execFileSync (child_process.js:647:13)
at runOnAllDevices (C:\ReactNative\testproj\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:74:39)
at buildAndRun (C:\ReactNative\testproj\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\index.js:158:41)
at then.result (C:\ReactNative\testproj\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\index.js:125:12)
at process._tickCallback (internal/process/next_tick.js:68:7)
请帮忙
【问题讨论】:
-
您的 JAVA_HOME 设置错误,重新设置,一切正常...
-
先生,“再次进行设置”是什么意思?我在 env 中浏览我的 JAVA_HOME 路径,像这样 C:\Program Files (x86)\Java\jre1.8.0_221,对吗?
-
thewindowsclub.com/set-java_home-in-windows-10 也许这会有所帮助!看看那里缺少什么...
-
它就像一个魅力!谢谢楼主!
-
很高兴有帮助!请务必将我的答案标记为解决方案:)
标签: react-native