【问题标题】:Failed to launch emulator. Reason: No emulators found as an output of `emulator -list-avds`无法启动模拟器。原因:没有找到模拟器作为 `emulator -list-avds` 的输出
【发布时间】:2021-05-08 16:56:40
【问题描述】:

我从 React-native 开始,并且已经安装并启动了模拟器。它工作正常,但是当我尝试运行时

react-native run-android

我在控制台中得到这些

$ react-native run-android
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
(node:12384) Warning: Accessing non-existent property 'padLevels' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
Jetifier found 970 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...

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.2/userguide/command_line_interface.html#sec:command_line_warnings

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':app:installDebug'.
> SDK location not found. Define location with an ANDROID_SDK_ROOT environment variable or by setting the sdk.dir path in your project's local properties file at 'C:\##\ShoppingList\android\local.properties'.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 3s

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

我尝试删除“宽数据”和./gradlew clean,但都不起作用

谢谢

【问题讨论】:

    标签: javascript android node.js react-native react-native-android


    【解决方案1】:

    我忘了提到这是我在 Windows 机器上运行它。我的问题没有这个: JDK

    现在很好用

    【讨论】:

      【解决方案2】:

      方法一:

      1. 转到您的 React-native 项目 -> Android
      2. 创建文件 local.properties
      3. 打开文件
      4. 如下所示粘贴您的 Android SDK 路径
      5. sdk.dir = C:\Users\USERNAME\AppData\Local\Android\sdk 将 USERNAME 替换为您的用户名

      现在,在终端中运行 react-native run-android。

      方法二:

      1. 打开 Windows 控制面板。
      2. 点击用户账户,然后再次点击用户账户
      3. 点击更改我的环境变量点击
      4. 在 New... 上创建一个新的 ANDROID_HOME 用户变量,该变量指向 Android SDK 的路径:

      【讨论】:

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