【问题标题】:Android development environment set up issue came while trying to run react native app尝试运行反应本机应用程序时出现Android开发环境设置问题
【发布时间】:2020-04-19 10:18:33
【问题描述】:

我目前正在尝试运行 React Native 应用程序,但在 Windows 10 中出现此错误。

ERROR: JAVA_HOME is set to an invalid directory: C:\Program Files\Java\jdk1.8.0_251;

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:630:11)
    at execFileSync (child_process.js:648:15)
    at runOnAllDevices (C:\Users\User\Desktop\crate\crate\code\mobile\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:94:39)
    at buildAndRun (C:\Users\User\Desktop\crate\crate\code\mobile\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\index.js:179:41)
    at C:\Users\User\Desktop\crate\crate\code\mobile\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\index.js:133:12
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async Command.handleAction (C:\Users\User\Desktop\crate\crate\code\mobile\node_modules\react-native\node_modules\@react-native-community\cli\build\index.js:182:9)

我已经在image 中安装了 java 及其工作方式

另外,我在使用这个代码 react-native run-android 之前运行模拟器,就像在这个image 它也给了我这个错误,但模拟器工作。

Failed to open /qemu.conf, err: 2

在这种情况下我做错了什么?

【问题讨论】:

    标签: react-native cmd android-emulator


    【解决方案1】:

    您可以在this 上查看相同的问题。编辑您的环境变量。

    1. 转到用户变量并编辑路径并添加 %JAVA_HOME%\bin。
    2. 现在在您的系统变量环境中:编辑路径并单击新建并添加此 C:\Program Files\Java\jdk1.8.0_241\bin
    3. 再次在系统变量环境中单击路径并单击新建添加此行 C:\Program Files (x86)\Common Files\Oracle\Java\javapath
    4. 现在保存并重新启动系统。这会对你有所帮助。

    【讨论】:

      【解决方案2】:

      您需要设置运行 react native android build 时将调用的 JAVA_HOME 环境变量。

      Setup guide for JAVA_HOME.

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2018-01-25
        • 1970-01-01
        • 2018-06-19
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多