Gaurav Pandit
Gaurav Pandit

Reputation: 977

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.

Upvotes: 11

Views: 3949

Answers (1)

danaimset
danaimset

Reputation: 364

  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:

Upvotes: 32

Related Questions