【问题标题】:error Failed to launch emulator. Reason: No emulators found as an output of `emulator -list-avds`. in windows 10错误无法启动模拟器。原因:没有找到模拟器作为 `emulator -list-avds` 的输出。在 Windows 10 中
【发布时间】:2020-04-27 15:58:50
【问题描述】:

您好,我是 react native 的新手,我已经按照文档安装了所有需要的工具来使用 android studio 运行 react-native。

这是我的 sdk 平台设置

这是我的 sdk 工具设置

我可以手动启动虚拟设备,它会显示并正常工作,

但是当我运行react-native run-android 时,我收到以下错误

PS C:\custom-xammp\htdocs\shoppingList> react-native run-android
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 963 file(s) to forward-jetify. Using 8 workers...
info JS server already running.
'adb' is not recognized as an internal or external command,
operable program or batch file.
info Launching emulator...
error Failed to launch emulator. Reason: No emulators found as an output of `emulator -list-avds`.
warn Please launch an emulator manually or connect a device. Otherwise app may fail to launch.
info Installing the app...

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.

    error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup. Run CLI with --verbose flag for more details.
    Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081

        at makeError (C:\custom-xammp\htdocs\shoppingList\node_modules\execa\index.js:174:9)
        at Promise.all.then.arr (C:\custom-xammp\htdocs\shoppingList\node_modules\execa\index.js:278:16)
        at process._tickCallback (internal/process/next_tick.js:68:7)
    PS C:\custom-xammp\htdocs\shoppingList> 

我需要做什么来解决这个问题?

【问题讨论】:

    标签: android react-native android-studio


    【解决方案1】:

    您需要将 JAVA_HOME(可能还有一些其他变量)添加到 PATH。

    首先:找到你的Java安装目录

    如果您在安装过程中没有更改路径,那将是一些东西 比如 C:\Program Files\Java\jdk[...]

    如果没有找到,请尝试重新安装java JDK(可以找到here

    然后执行以下操作之一:

    Windows 7: 右键单击​​我的电脑并选择属性 > 高级

    Windows 8: 进入控制面板 > 系统 > 高级系统设置

    Windows 10: 搜索环境变量然后选择编辑 系统环境变量

    然后:

    单击环境变量按钮。

    在系统变量下,单击新建。

    在变量名称字段中,输入JAVA_HOME

    在变量值字段中,输入您的 JDK 安装路径。

    如果路径包含空格,请使用缩短的路径名。例如C:\Programs\Java\jdk1.8.0_65

    [edit] 我知道你也需要安装 adb

    使用 this 链接下载适用于 Windows 的 ADB ZIP 文件

    将此 ZIP 文件的内容解压缩到一个易于访问的文件夹中(例如 C:\adb)

    打开 Windows 资源管理器并浏览到您提取此 ZIP 文件内容的位置

    然后从与此 ADB 二进制文件相同的目录中打开命令提示符。这可以通过在文件夹中按住 Shift 并右键单击然后单击“在此处打开命令提示符”选项来完成。 (某些 Windows 10 用户可能会看到“PowerShell”而不是“命令提示符”。)安装 adb

    确保在你的 windows 机器上安装了一个 android 模拟器,你可能会使用 AVD,所以在 Android Studio 屏幕上打开 AVD Manager 并创建一个(如果你没有),然后在运行 @987654328 之前运行它@命令

    【讨论】:

      猜你喜欢
      • 2021-05-08
      • 2020-05-26
      • 2020-03-12
      • 1970-01-01
      • 2021-04-14
      • 2020-10-01
      • 1970-01-01
      • 1970-01-01
      • 2022-10-21
      相关资源
      最近更新 更多