修复MacOS Big Sur 下 Android模拟无法运行
作者:互联网
修复MacOS Big Sur 下 Android模拟无法运行
系统版本:MacOS Big Sur 11.3
Android emulator版本:30.5.5
表现
系统升级后Android模拟器无法运行,通过命令行启动模拟器运行报错如下:
% emulator -feature HVF -avd Pixel_2_API_29
handleCpuAcceleration: feature check for hvf
emulator: INFO: QtLogger.cpp:68: Warning: QMetaObject::connectSlotsByName: No matching signal for on_new_posture_requested(int) ((null):0, (null))
emulator: INFO: QtLogger.cpp:68: Warning: QMetaObject::connectSlotsByName: No matching signal for on_dismiss_posture_selection_dialog() ((null):0, (null))
cannot add library /Users/zhangzhenli/Library/Android/sdk/emulator/qemu/darwin-x86_64/lib64/vulkan/libvulkan.dylib: failed
added library ./lib64/vulkan/libvulkan.dylib
cannot add library /Users/zhangzhenli/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 ./lib64/vulkan/libMoltenVK.dylib
emulator: INFO: GrpcServices.cpp:301: Started GRPC server at 127.0.0.1:8554, security: Local
问题原因
谷歌爬了一些发现了大概,简单说就是Big Sur 11.3针对安全性做了升级,现有的qemu没有及时适配。
解决方法
要解决此问题,我们要做的就是为qemu-system-x86_64二进制添加新的权限声明。
- 创建一个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>
- 签名qemu二进制文件:
~ % cd ~/Library/Android/sdk/emulator/
emulator % codesign -s - --entitlements entitlements.xml --force ~/Library/Android/sdk/emulator/qemu/darwin-x86_64/qemu-system-x86_64
- 再次启动
emulator % ./emulator -list-avds
Pixel_2_API_29
emulator %./emulator -feature HVF -avd Pixel_2_API_29
handleCpuAcceleration: feature check for hvf
emulator: INFO: QtLogger.cpp:68: Warning: QMetaObject::connectSlotsByName: No matching signal for on_new_posture_requested(int) ((null):0, (null))
emulator: INFO: QtLogger.cpp:68: Warning: QMetaObject::connectSlotsByName: No matching signal for on_dismiss_posture_selection_dialog() ((null):0, (null))
cannot add library /Users/zhangzhenli/Library/Android/sdk/emulator/qemu/darwin-x86_64/lib64/vulkan/libvulkan.dylib: failed
added library ./lib64/vulkan/libvulkan.dylib
cannot add library /Users/zhangzhenli/Library/Android/sdk/emulator/qemu/darwin-x86_64/lib64/vulkan/libMoltenVK.dylib: failed
added library ./lib64/vulkan/libMoltenVK.dylib
emulator: INFO: GrpcServices.cpp:301: Started GRPC server at 127.0.0.1:8554, security: Local
以上HVF error: HV_ERROR错误消除,成功启动了。
参考原文
链接: https://www.arthurkoziel.com/qemu-on-macos-big-sur/.
标签:MacOS,x86,Big,library,64,Sur,Android,qemu,emulator 来源: https://blog.csdn.net/sxser/article/details/116235497