简体   繁体   English

无法启动模拟器。 原因:模拟器在启动前退出 en React Native when react-native run-android

[英]Failed to launch emulator. Reason: Emulator exited before boot en React Native when react-native run-android

I am installing React Native according to this website https://medium.com/@leonardobrunolima/react-native-tips-setting-up-your-development-environment-for-windows-d326635604ea , it's very useful until I run the command react-native run-android , this is the error I receive:我正在根据这个网站https://medium.com/@leonardobrunolima/react-native-tips-setting-up-your-development-environment-for-windows-d326635604ea安装 React Native,在我运行命令之前它非常有用react-native run-android ,这是我收到的错误:

info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 864 file(s) to forward-jetify. Using 8 workers...
info Starting JS server...
info Launching emulator...
error Failed to launch emulator. Reason: Emulator exited before boot..
> Task :app:transformNativeLibsWithMergeJniLibsForDebug FAILED

Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.5/userguide/command_line_interface.html#sec:command_line_warnings
24 actionable tasks: 4 executed, 20 up-to-date

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:transformNativeLibsWithMergeJniLibsForDebug'.
> Could not read path 'C:\JesusApp\android\app\build\intermediates\transforms\mergeJniLibs\debug\0\lib\x86_64'.

* 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 7s

error Failed to install the app. Make sure you have the Android development environment set up: https://facebook.github.io/react-native/docs/getting-started.html#android-development-environment. Run CLI with --verbose flag for more details.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:transformNativeLibsWithMergeJniLibsForDebug'.
> Could not read path 'C:\JesusApp\android\app\build\intermediates\transforms\mergeJniLibs\debug\0\lib\x86_64'.

* 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 7s

    at checkExecSyncError (child_process.js:629:11)
    at execFileSync (child_process.js:647:13)
    at runOnAllDevices (C:\JesusApp\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:94:39)
    at process._tickCallback (internal/process/next_tick.js:68:7)
    

My node version is 10, and I am working on Windows, please help, thank you.我的node版本是10,我在windows下工作,请帮忙,谢谢。

  1. Check your config and environment setup with instructions here , be very careful with pathes set up.使用此处的说明检查您的配置和环境设置,设置路径时要非常小心。 Check the $PATH from your IDE's terminal.从 IDE 的终端检查 $PATH。
  2. check in the AVD that a particular Android OS is selected and installed for a virtual device you use (in my case it was not, I had yellow warning exclaim sign in an "Actions" column in an AVD's devices list).检查 AVD 是否为您使用的虚拟设备选择并安装了特定的 Android 操作系统(在我的情况下,它不是,我在 AVD 的设备列表中的“操作”列中有黄色警告感叹号)。
  3. Have your Gradle updated to at least 6.6 in the将您的 Gradle 更新到至少 6.6

android/gradle/wrapper/gradle-wrapper.properties android/gradle/wrapper/gradle-wrapper.properties

  1. On Ubuntu after run I had to "push" switch-on button on the virtual device.在运行后的 Ubuntu 上,我必须“按下”虚拟设备上的开机按钮。

Finally, I got it up and running both on Windows 10 and Ubuntu 20.04 LTS with Android 30.最后,我在 Windows 10 和带有 Android 30 的 Ubuntu 20.04 LTS 上启动并运行了它。

我通过执行以下步骤成功:打开 android studio > AVD Manager > Actions(单击底部图标)> Select Cool Boot Now。

First start the android emulator on Android Studio, then execute the react-native run-android.首先在Android Studio上启动android模拟器,然后执行react-native run-android。 If it doesn´t work go to android studio and do "Build -> Clean Project"如果它不起作用,请转到 android studio 并执行“Build -> Clean Project”

In my case, I've to wipe data on the virtual device.就我而言,我必须擦除虚拟设备上的数据。 Android Studio -> AVD -> Actions (↓) -> Wipe Data Android Studio -> AVD -> 操作 (↓) -> 擦除数据

I faced similar problem when executing my react-native code on Android Physical device.Android 物理设备上执行我的 react-native 代码时,我遇到了类似的问题。 I am not sure if my solution will help.我不确定我的解决方案是否会有所帮助。

We all know that ADB requires authorization from an Android device in order to communicate with it.我们都知道 ADB 需要 Android 设备的授权才能与其通信。 It's only by allowing the USB debugging and validating the computer's RSA key fingerprint that we let the ADB daemon connect to our phone and control it.只有通过允许 USB 调试和验证计算机的 RSA 密钥指纹,我们才能让 ADB 守护程序连接到我们的手机并控制它。 This is a security feature.这是一项安全功能。

My phone was connected with USB and on changing USB Configuration on device, my phone gave me another prompt "Allow USB debugging?"我的手机已通过 USB 连接,并且在更改设备上的 USB 配置时,我的手机给了我另一个提示“允许 USB 调试?” Image available for reference .图片可供参考 I got solution on reallow USB debugging我得到了关于真正的USB 调试的解决方案

我遇到了同样的问题,只检查开发人员选项并在设备上通过usb启用调试

For me, the problem ended up being quite simple.对我来说,问题最终变得非常简单。 Working in react-native, I was running the following command from the terminal 'npx react-native run-android' in VS CODE.在 react-native 中工作,我从 VS CODE 中的终端“npx react-native run-android”运行以下命令。 Though the emulator would run fine when started from Android Studios, I received the above error when running from the terminal in VS Code.虽然模拟器从 Android Studios 启动时运行良好,但在 VS Code 中从终端运行时收到上述错误。

Solution: Run VS Code as Administrator.解决方案:以管理员身份运行 VS Code。 (or your terminal in general) (或您的一般终端)

为我工作-磁盘上没有足够的空间,检查磁盘上是否有足够的空间(模拟器安装在哪里)。

This might be the insufficient space in your machine or AVD or the mismatch in the configurations.这可能是您的机器或 AVD 中的空间不足或配置不匹配。

So, do the following steps to resolve this issue.因此,请执行以下步骤来解决此问题。

  • Verify that the environment variables are set for SDK path and adb.验证是否为 SDK 路径和 adb 设置了环境变量。
  • Clean the project by Build -> Clean Project通过Build -> Clean Project
  • Clean AVD by Open android studio > AVD Manager > Actions (click the bottom icon) > Select Cool Boot Now .通过Open android studio > AVD Manager > Actions (click the bottom icon) > Select Cool Boot Now来清理 AVD。

In my case, cool boot and wipe data didn't work.就我而言,冷启动和擦除数据不起作用。 I just uninstall the virtual device and reinstall it and then it works for me.我只是卸载虚拟设备并重新安装它,然后它对我有用。

为我工作 - 重新加载系统或清理系统/android缓存./android/avd

For me running对我来说跑步

adb kill-server

and

adb start-server

worked工作过

I also runned killall 9 node before that but it was not enough.在此之前我也运行了killall 9 node ,但这还不够。 MacOS asks for saving last state before restart also Android emulator asks before quiting it. MacOS 要求在重启之前保存最后一个状态,Android 模拟器也会在退出之前询问。 Maybe the problem happens because saving a bad state and trying to start from that bad state.也许问题的发生是因为保存了一个糟糕的状态并试图从那个糟糕的状态开始。 Not sure but I suspect one of these.不确定,但我怀疑其中之一。

删除文件app\build\intermediates\signing_config\debug\out\signing-config.json对我有用。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 React Native,无法启动模拟器。 原因:没有找到模拟器作为输出 - React Native, Failed to launch emulator. Reason: No emulators found as an output react-native run-android未检测到模拟器或设备 - react-native run-android not detecting emulator or device 类型错误:尝试从 android 模拟器访问本地 API 时网络请求失败。 React-Native - TypeError: Network Request Failed when trying to hit local API from android emulator. React-Native 当为运行模拟器adb android studio运行react-native run-android时,显示错误app:installDebug FAILED - When run react-native run-android for run emulator adb android studio, show error app:installDebug FAILED React Native WebStorm Emulator 无法启动 - 错误无法启动模拟器。 原因:找不到模拟器作为 `emulator -list-avds` 的 output - React Native WebStorm Emulator cannot start - error Failed to launch emulator. Reason: No emulators found as an output of `emulator -list-avds` 即使连接了 android 设备,React Native run-android 也总是启动模拟器 - React Native run-android always launch emulator even when android device connected 即使在模拟器运行时,React Native 也无法运行-android - React native fail to run-android even when emulator running React Native:react-native run-android 没有启动 Android 模拟器 - React Native: react-native run-android is not starting Android emulator npx react-native run-android 不启动模拟器,如果模拟器正在运行则不运行 - npx react-native run-android doesn't start emulator and doesn't run if emulator is running react-native run-android 失败 - react-native run-android Failed
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM