Android emulators are not working on macOS Big Sur 11.3+

Duna picture Duna · Aug 25, 2020 · Viewed 23.9k times · Source

I have upgraded the mac OS to Big Sur and none of the emulators are working. It seems that all Android emulators Fails on Mac OS Big Sur Beta. I deleted the old emulators and created new ones with different HW/SW, unsuccessfully. Introduced the following issues in the android emulator.

  1. ffffffffb69b4dbb: unhandled exit 1d
  2. Emulator Engine Failed
  3. adb Device Offline

https://issuetracker.google.com/issues/165038831

Does anyone have a solution?

EDIT 27.04.2021

~/Library/Android/sdk/emulator/emulator -gpu host -read-only -feature HVF -avd Pixel_4_API_29
emulator: Android emulator version 30.5.5.0 (build_id 7285888) (CL:N/A)
handleCpuAcceleration: feature check for hvf
cannot add library /Users/dunatv/Library/Android/sdk/emulator/qemu/darwin-x86_64/lib64/vulkan/libvulkan.dylib: failed
added library /Users/dunatv/Library/Android/sdk/emulator/lib64/vulkan/libvulkan.dylib
cannot add library /Users/dunatv/Library/Android/sdk/emulator/qemu/darwin-x86_64/lib64/vulkan/libMoltenVK.dylib: failed
HVF error: HV_ERROR
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
added library /Users/dunatv/Library/Android/sdk/emulator/lib64/vulkan/libMoltenVK.dylib
emulator: INFO: GrpcServices.cpp:301: Started GRPC server at 127.0.0.1:8554, security: Local

Answer

Markymark picture Markymark · Apr 28, 2021

Update: this should now be fixed by version 30.5.6 of the Android emulator in the stable channel.

However, if you are now experiencing issues after updating to the latest version of the Android Emulator you can fix this by removing and then adding back the Android Emulator from the SDK Manager.

Tools > SDK Manager > SDK Tools
Uncheck Android Emulator and hit apply.
Check Android Emulator and hit apply.


Original answer:

This worked for me https://www.arthurkoziel.com/qemu-on-macos-big-sur

Essentially, create an XML file called entitlements.xml with the following contents:

<?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>

Copy the XML file to ~/Library/Android/sdk/emulator/qemu/darwin-x86_64

Then run the following commands in terminal:

codesign -s - --entitlements entitlements.xml --force qemu-system-aarch64
codesign -s - --entitlements entitlements.xml --force qemu-system-aarch64-headless 
codesign -s - --entitlements entitlements.xml --force qemu-system-armel
codesign -s - --entitlements entitlements.xml --force qemu-system-armel-headless 
codesign -s - --entitlements entitlements.xml --force qemu-system-i386
codesign -s - --entitlements entitlements.xml --force qemu-system-i386-headless 
codesign -s - --entitlements entitlements.xml --force qemu-system-x86_64
codesign -s - --entitlements entitlements.xml --force qemu-system-x86_64-headless