React Native,无法启动模拟器。原因:找不到仿真器作为输出

时间:2020-10-21 08:07:38

标签: javascript android react-native

我正在尝试通过使用命令react-native run-android在模拟器中运行我的react native应用,但是它抛出了该错误

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.3/userguide/command_line_interface.html#sec:command_line_warnings

BUILD SUCCESSFUL in 44s
info Connecting to the development server...
warn Failed to connect to development server using "adb reverse": spawnSync /Opt/Android/platform-tools/adb ENOENT
info Starting the app...
The system cannot find the path specified.
error Failed to start the app. Run CLI with --verbose flag for more details.
Error: Command failed: /Opt/Android/platform-tools/adb shell am start -n com.reactproject/com.reactproject.MainActivity
    at makeError (C:\Users\Danger World\ReactProject\node_modules\execa\index.js:174:9)

我已经设置了我的android studio和sdk管理器,像doc中所示的avd管理器,我也已经设置了路径,但是它仍然显示该错误,有人知道为什么吗?有人可以帮忙吗?

3 个答案:

答案 0 :(得分:9)

您可以使用以下命令修复它:

react-native doctor

此命令显示需要修复的所有问题。

enter image description here

按 f 解决问题,不要忘记重新启动 Windows

然后在运行您的项目之前打开模拟器。 打开模拟器后, 运行命令: react-native run-android

修复后:

enter image description here

如果可行,请不要忘记给我点赞。

答案 1 :(得分:3)

就我而言,我必须在您尝试运行 npx react-native run-android

的同一终端中重新运行该命令

第一步,先粘贴源命令

<块引用>

源 ~/.bash_profile 或源 ~/.bashrc

第 2 步:运行下一个命令

<块引用>

npx react-native run-android

答案 2 :(得分:1)

像这样设置您的AVD管理器路径和JDK路径,还必须添加Android Home路径 Environment variables