无法启动模拟器。原因:没有找到模拟器作为 `emulator -list-avds` 的输出

Failed to launch emulator. Reason: No emulators found as an output of `emulator -list-avds`

我开始使用 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,但均无效

谢谢

我忘了说这是我 运行 在 windows 机器上的。我的问题不是这个: JDK

现在效果很好

方法一:

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

现在,运行 终端中的原生反应 运行-android。

方法二:

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