25

So my Mac just forced updated to Big Sur 11.3. I've been trying to access the Android Device Manager to run an emulated device and it has been silently failing each time. When I tried to run it from the command line, I get this error message:

emulator @Pixel_3a_API_30
emulator: Android emulator version 30.5.5.0 (build_id 7285888) (CL:N/A)
handleCpuAcceleration: feature check for hvf
cannot add library /Users/centuryfall/Library/Android/sdk/emulator/qemu/darwin-x86_64/lib64/vulkan/libvulkan.dylib: failed
added library /Users/centuryfall/Library/Android/sdk/emulator/lib64/vulkan/libvulkan.dylib
cannot add library /Users/centuryfall/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
Failed to open the hax module
No accelerator found.
qemu-system-x86_64: failed to initialize HAX: Operation not supported by device
added library /Users/centuryfall/Library/Android/sdk/emulator/lib64/vulkan/libMoltenVK.dylib

(Replaced actual username with "centuryfall").

I've looked at some other questions that say that the AVD needs to be version 30. I have AVD v30.5.5.0 Has anyone else had this issue?

centuryfall
  • 400
  • 2
  • 5
  • 13

5 Answers5

57

Update 2021-04-29: Emulator version 30.5.6 now in stable channel and it fixes this issue. Old answer preserved below.


Apple has changed hypervisor entitlements (permissions), deprecating com.apple.vm.hypervisor with com.apple.security.hypervisor. Before Google fixes emulator code signing with the new entitlements you can work around the issue by granting the entitlement yourself.

Create a 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>

and run

codesign -s - --entitlements entitlements.xml --force /usr/local/bin/qemu-system-x86_64

Replace qemu path as necessary where your SDK is located. Could be e.g. ~/Library/Android/sdk/emulator/qemu/darwin-x86_64/qemu-system-x86_64 on some SDK installations.

Answer based on https://www.arthurkoziel.com/qemu-on-macos-big-sur/

Related issues:

laalto
  • 150,114
  • 66
  • 286
  • 303
  • 6
    Lost only one day trying to get it to work, could be worse lol. Thanks ! – Dokuzov Apr 27 '21 at 19:59
  • 3
    If the above doesn't work, check if you are using the 32bit version of Qemu, then qemu-system-x86_64 should be replaced with qemu-system-i386. Likewise for other architectures. – Rasmus Friis Kjeldsen Apr 28 '21 at 08:12
  • Hi all, I can also not start the emulator. But my error message is different. Can you take a look for me, if they are the same problem? https://stackoverflow.com/questions/67307381/android-emulator-can-not-start-after-update-to-ios-big-sur-11-3-today – xirururu Apr 28 '21 at 20:31
  • Awesome solution fixed for me. Also a new version of Android Emulator 3.5.6 got release yesterday [28/4], does minor update fix the issue? Can someone confirm this? – DouggyC Apr 29 '21 at 01:05
  • Emulator 30.5.6 didn't fix it for me. Going to try this workaround – Jozua Apr 29 '21 at 13:45
  • I am tried above but getting below error: qemu-system-x86_64: replacing existing signature xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun qemu-system-x86_64: the codesign_allocate helper tool cannot be found or used – Girish Aug 25 '21 at 12:15
6

Update your emulator to get rid of this issue.

Follow the steps below:

In your android studio go to SDK Manager -> SDK Tools Tab

  1. Select Android Emulator and update it

OR

  1. Uncheck Android Emulator and apply
  2. Check Android Emulator and apply

If you want to stay with the Android Emulator version below 30.5.6 you can follow the steps mentioned in the accepted answer here

Rishabh Saxena
  • 1,765
  • 15
  • 26
  • Yes, I've seen the patch and have already updated my emulator. I had asked the question prior to that release being pushed, and I've already accepted the earlier answer above as the solution that I've needed. – centuryfall May 10 '21 at 16:27
  • Yeah, but many guys are not aware of this patch. So this answer will help them so upvote will help others in terms of visibility & fixing it when they will run in to this situation. – Rishabh Saxena May 11 '21 at 17:27
  • 1
    Confirmed this worked for me. I installed Android studio today and I had to use Tools->SDK Manager->SDK Tools – Daniel Kaplan May 30 '21 at 06:00
  • 2
    This is what did it for me. I already had the latest version of the Android Emulator installed, but removing and re-adding it with these steps resolved the issue – daentech Jun 04 '21 at 08:30
2

If you get entitlements.xml: cannot read entitlement data error you should start the terminal at folder which include qemu-system-x86_64 file.

For example my qemu-system-x86_64 file is in this location : /Users/yourusername/Library/Android/sdk/emulator/qemu/darwin-x86_64/qemu-system-x86_64

Now right click on darwin-x86_64 folder and click New terminal Tab at Folder. Don't forget the copy your entitlements.xml file into the darwin-x86_64 folder. Now in this terminal run the command which @laalto said. If you have any question, i'll gladly answer.

Dharman
  • 30,962
  • 25
  • 85
  • 135
UmutTekin
  • 216
  • 2
  • 15
1

For those who using Xamarin:

Visual Studio Mac Go to Preference. Click on Android, it will prompt you for SDK repair. Click on it and it should fix it.

enter image description here

If you are using Rider, go Preference, Android and update the Emulator SDK:

enter image description here

Visual Sharp
  • 3,093
  • 1
  • 18
  • 29
1

I installed Android studio today and confirmed that updating is still needed.

Use Tools->SDK Manager->SDK Tools to update the two packages. Then make a new emulator.

Now emulator --version shows 30.6.5.0 and the command emulator -avd tak -gpu host launches the hardware accelerated emulator without an issue.

Side note: The emulator output still throws two "cannot add library" lines that are followed by "added library" though it seems to launch just fine.

P.s. Don't forget to set your environment variables in your .bashrc or .zshrc

export ANDROID_SDK_ROOT=/Users/dan/Library/Android/sdk
export PATH="$PATH:/Users/dan/Library/Android/sdk/emulator"
export PATH="$PATH:/Users/dan/Library/Android/sdk/tools"
Daniel Kaplan
  • 222
  • 1
  • 8