android 模拟器总是给出错误 emu-crash-xx-xx.db 并在打开完成之前退出

问题描述 投票:0回答:1

我已经在 Windows 中完成了 React Native 的新设置: 每当我尝试从命令启动模拟器时,我都会遇到这个问题,但我可以在 android studio 中打开模拟器,没有任何问题

> react-native run-android

* daemon not running; starting now at tcp:5037
* daemon started successfully
info Launching emulator...
error Failed to launch emulator. Reason: The emulator (INFO    | Storing crashdata in: C:\Users\arunk\AppData\Local\Temp\\AndroidEmulator\emu-crash-34.1.18.db, detection is enabled for process: 13500) quit before it finished opening. You can try starting the emulator manually from the terminal with: C:\Users\arunk\AppData\Local\Android\Sdk/emulator/emulator @INFO    | Storing crashdata in: C:\Users\arunk\AppData\Local\Temp\\AndroidEmulator\emu-crash-34.1.18.db, detection is enabled for process: 13500.
warn Please launch an emulator manually or connect a device. Otherwise app may fail to launch.
info Installing the app...
BUILD FAILED in 19s
error Failed to install the app. Command failed with exit code 1: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081 FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':app:installDebug'. > com.android.builder.testing.api.DeviceException: No online devices found. * 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 19s.

也在 github 上提出了问题 text

我正在尝试运行 android 模拟器 usign

npm run android 

npx react-native run-android

预期:metro启动后android模拟器应该自动启动 但它每次都失败并给出这个 emu-crash.db 日志问题

也尝试删除该日志文件 也尝试运行不同版本的 React Native

android react-native android-emulator metro-bundler
1个回答
0
投票

首先。你只从 VSCode 运行它还是也从 Android Studio 运行它?

尝试从 android studio 运行它,看看是否出现相同的错误。 另外,尝试运行模拟器,然后运行 package.json 中的命令。

您还可以尝试以下节点命令

"android": "lsof -ti :8081 | xargs kill -9 && rm -rf node_modules && rm -f package-lock.json && npm i --legacy-peer-deps && cd android && ./gradlew clean && cd .. && react-native start --reset-cache"

该命令将终止端口 8081,删除 node_modules 和 package-lock.json。之后它将再次安装所有依赖项并 cd 到 android 文件夹并清理 gradle 文件夹。最后使用 --reset-cache 标志运行地铁。

如果有帮助请告诉我。

© www.soinside.com 2019 - 2024. All rights reserved.