在React Native运行Android时遇到的问题

时间:2019-09-13 01:05:18

标签: react-native

我最近在Windows PC上安装了React Native,并创建了一个项目,但是当我尝试将react-native run-android用于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)

请帮助

1 个答案:

答案 0 :(得分:1)

您的JAVA_HOME设置不正确,请重新进行设置,一切都应正常进行... 您可以参考this并检查缺少的内容...