Android Emulator does not start on macOs Fix

/ April 29, 2021/ Android, macOS, Programming

(Last Updated On: April 29, 2021)

Or How to Fix android emulator HV_ERROR that triggers “The emulator process for avd was killed” problem.

I got this problem after update my macOs to Big Sur 11.3 but this can also happen in other macOs versions. After I wanted to start the emulator from Android Studio like always this popup was presented to me:

AVD was Killed Error Popup

Failing Intents

I was a good couple of hours (if not more) trying to find a fix for this without success, I tried:

  • Reinstall the emulator in Android Studio SDK manager
  • Reinstall HAXM
  • Change the emulator graphics to just software/hardware
  • Update everything Android

Console output

Nothing worked. Since I did not knew what was trigger the problem I went to where the emulator executable is in my mac: ~/Library/Android/sdk/emulator and I started the emulator manually with. ./emulator -avd Pixel_3a_API_30. This was the output

emulator: Android emulator version (build_id 7285888) (CL:N/A)
handleCpuAcceleration: feature check for hvf
cannot add library /Users/saninn/Library/Android/sdk/emulator/qemu/darwin-x86_64/lib64/vulkan/libvulkan.dylib: failed
added library /Users/saninn/Library/Android/sdk/emulator/lib64/vulkan/libvulkan.dylib
qemu-system-x86_64: failed to initialize HVF: Invalid argument
HAX is working and emulator runs in fast virt mode.
qemu-system-x86_64: Back to HAX accelerator
emulator: INFO: GrpcServices.cpp:301: Started GRPC server at, security: Local

The important part there is:

qemu-system-x86_64: failed to initialize HVF: Invalid argument

After searching a little big more I found a reddit post about virtual machines where states the hidden problem:

Apple won’t let the QEMU binary run with -accel hvf unless the binary is signed. Every time hv_vm_create() runs, it returns an HV_ERROR.

Finally a fix

So, that’s it! we have to manually sign the binary!

To fix the problem we have to go to where our emulator app lives, in my case I went to ~/Library/Android/sdk/emulator/qemu/darwin-x86_64 and created a new file called app.entitlements with this content:

<?xml version="1.0" encoding="utf-8"?>

<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">

<plist version="1.0"> <dict> <key></key> <true/> </dict> </plist>

After we sign it with codesign -s -- --entitlements app.entitlements --force qemu-system-x86_64

That’s it! your emulator should be working again!

Spread the love
Notify of
Inline Feedbacks
View all comments