Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android emulator crash when start. HVF error: HV_ERROR

Running the emulator on MacBook Air 2017 (Version 11.4 Beta)

The idea logs of emulator :

Emulator: /Users/gaurav12/Android_SDK/emulator/emulator -netdelay none -netspeed full -avd Pixel_2_API_30 Emulator: handleCpuAcceleration: feature check for hvf Emulator: cannot add library /Users/gaurav12/Android_SDK/emulator/qemu/darwin-x86_64/lib64/vulkan/libvulkan.dylib: failed Emulator: HVF error: HV_ERROR Emulator: qemu-system-x86_64: failed to initialize HVF: Invalid argument Emulator: Failed to open the hax module Emulator: No accelerator found. Emulator: qemu-system-x86_64: failed to initialize HAX: Operation not supported by device Emulator: added library /Users/gaurav12/Android_SDK/emulator/lib64/vulkan/libvulkan.dylib Emulator: cannot add library /Users/gaurav12/Android_SDK/emulator/qemu/darwin-x86_64/lib64/vulkan/libMoltenVK.dylib: failed enter image description hereEmulator: added library /Users/gaurav12/Android_SDK/emulator/lib64/vulkan/libMoltenVK.dylib 2021-04-26 14:53:28,526 [ 187258] WARN - n.process.BaseOSProcessHandler - Process hasn't generated any output for a long time.

like image 421
Gaurav Pandit Avatar asked Apr 26 '21 09:04

Gaurav Pandit


People also ask

How do I fix Android Emulator not working?

If the Android Emulator does not start properly, this problem is often caused by problems with HAXM. HAXM issues are often the result of conflicts with other virtualization technologies, incorrect settings, or an out-of-date HAXM driver. Try reinstalling the HAXM driver, using the steps detailed in Installing HAXM.

How solve Android emulator closed because of internal error?

This error sometimes occurs because of out of date components like 'Android Emulator' or 'Android SDK Platform-Tools' components. Just update all pending updates, then Invalidate Caches & Restart, then try to create a new AVD.


1 Answers

  1. Navigate to folder containing qemu binary (e.g. ~/Library/Android/sdk/emulator/qemu/darwin-x86_64)

  2. Create file entitlements.xml with the following content:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
        <key>com.apple.security.hypervisor</key>
        <true/>
    </dict>
    </plist>
    
  3. Make sure you have XCode command line tools installed

    sudo xcode-select --install

  4. Resign qemu binary:

    codesign -s - --entitlements entitlements.xml --force ./qemu-system-x86_64

References:

  • https://www.arthurkoziel.com/qemu-on-macos-big-sur/
  • https://www.reddit.com/r/MacOS/comments/ltp77a/anyone_using_qemu_for_linux_on_macos_big_sur/
  • https://www.reddit.com/r/VFIO/comments/kdhgni/qemu_hvf_support_for_mac_os_x_bug_sur_hv_error/
like image 72
danaimset Avatar answered Oct 25 '22 06:10

danaimset