You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Windows10运行React Native应用遇JAVA_HOME无效与模拟器错误求助

Troubleshooting React Native Run Errors on Windows 10

Let’s work through your issues step by step with practical fixes:

1. Fix the Invalid JAVA_HOME Directory Error

The error explicitly flags a trailing semicolon in your JAVA_HOME path (C:\Program Files\Java\jdk1.8.0_251;)—this is a common Windows environment variable mistake. Here’s how to fix it:

  • Right-click This PC → Properties → Advanced System Settings → Environment Variables.
  • Under System Variables, find and edit the JAVA_HOME entry.
  • Set its value to C:\Program Files\Java\jdk1.8.0_251 (remove the trailing semicolon entirely).
  • Double-check the path exists: Navigate to the folder in File Explorer to confirm your JDK hasn’t been moved or renamed.
  • Critical step: Close all open command prompts/terminals and open a new one—environment variable changes only take effect in fresh sessions.
  • Verify the fix: Run echo %JAVA_HOME% and java -version in the new terminal; both should return valid, error-free outputs.

2. Resolve Android Development Environment Configuration Issues

Even with a working emulator, misconfigured SDK paths can block app installation:

  • Check the ANDROID_HOME system variable: Ensure it points to your Android SDK root directory (typically C:\Users\<YourUsername>\AppData\Local\Android\Sdk).
  • Add SDK tools to your Path variable: Under System Variables > Path, add these two entries:
    • %ANDROID_HOME%\tools
    • %ANDROID_HOME%\platform-tools
  • Clean cached build files: Navigate to your React Native project root in the terminal and run gradlew clean to clear corrupted build artifacts.
  • Get detailed error logs: Run react-native run-android --verbose—this will output granular logs to pinpoint exactly where the installation fails.

3. Fix "Failed to open /qemu.conf, err: 2" Error

This error ties to the Android Emulator’s QEMU configuration:

  • Locate the qemu.conf file: It’s usually stored at C:\Users\<YourUsername>\AppData\Local\Android\Sdk\emulator\lib\qt\etc\qemu.conf.
  • If the file is missing: Open Android Studio’s SDK Manager, go to the SDK Tools tab, find Android Emulator, and reinstall it to restore missing files.
  • If the file exists: Check its permissions—right-click the file → Properties → Security tab, and ensure your user account has read access.
  • Reset your emulator: Open Android Studio’s AVD Manager, select your emulator, click Wipe Data, then restart the emulator to clear corrupted state.

After working through these steps, try running react-native run-android again—most likely your issues will be resolved.

内容的提问来源于stack exchange,提问作者Good man

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.07 11:33:12