Reputation: 409
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?
Upvotes: 25
Views: 13489
Reputation: 222
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"
Upvotes: 1
Reputation: 3996
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.
If you are using Rider, go Preference, Android and update the Emulator SDK:
Upvotes: 1
Reputation: 1795
Update your emulator to get rid of this issue.
Follow the steps below:
In your android studio go to SDK Manager -> SDK Tools Tab
OR
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
Upvotes: 6
Reputation: 152867
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:
Upvotes: 57
Reputation: 258
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.
Upvotes: 2