更新 Big Sur 11.3 后,Android 模拟器不工作或不显示

时间:2021-04-27 12:57:23

标签: android-studio android-emulator macos-big-sur

嗨,我今天将 mac os big sur 11.2 更新到 11.3。

I am using Android Studio 4.1.3
Build #AI-201.8743.12.41.7199119, built on March 10, 2021
Runtime version: 1.8.0_242-release-1644-b3-6915495 x86_64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
macOS 10.16
GC: ParNew, ConcurrentMarkSweep
Memory: 1979M
Cores: 16

Android Emulator 未打开,但它在 avd 管理器的 Dock 中打开。 我试过了 Big sur update from Stack Overflow。 但它对我不起作用,我按照给定的命令使用了

~/Library/Android/sdk/emulator/emulator -gpu host -feature HVF -avd 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/vmodi/Library/Android/sdk/emulator/qemu/darwin-x86_64/lib64/vulkan/libvulkan.dylib: failed
added library /Users/vmodi/Library/Android/sdk/emulator/lib64/vulkan/libvulkan.dylib
cannot add library /Users/vmodi/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/vmodi/Library/Android/sdk/emulator/lib64/vulkan/libMoltenVK.dylib

任何人都知道如何解决这个问题。

1 个答案:

答案 0 :(得分:4)

根据 this post,这似乎是 OSX 11.3 中更新的某些 hypervisor 权利的问题。

在模拟器应用程序中提供官方修复之前,可以通过创建一个包含以下内容的 entitlements.xml 文件来修复

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

然后运行

codesign -s - --entitlements entitlements.xml --force ~/Library/Android/sdk/emulator/qemu/darwin-x86_64/qemu-system-x86_64

(qemu 的路径可能需要根据 Android SDK 的安装路径进行调整)

这个解决方案也有人建议on other similar posts,为了方便,我在这里重复了一遍。