MacOS Android Studio 启动模拟器报错:feature check for hvf

最近发现 Android Studio 的模拟器运行不了,报错:

emulator: Android emulator version 30.9.5.0 (build_id 7820599) (CL:N/A)
handleCpuAcceleration: feature check for hvf
......
cannot add library /Users/aizawasayo/Library/Android/sdk/emulator/qemu/darwin-x86_64/lib64/vulkan/libvulkan.dylib: failed
added library /Users/aizawasayo/Library/Android/sdk/emulator/lib64/vulkan/libvulkan.dylib
cannot add library /Users/aizawasayo/Library/Android/sdk/emulator/qemu/darwin-x86_64/lib64/vulkan/libMoltenVK.dylib: failed
added library /Users/aizawasayo/Library/Android/sdk/emulator/lib64/vulkan/libMoltenVK.dylib

报错和应用状态忘记截屏了,反正模拟器是无响应状态。

后面百度到官方这篇解决了:【通过硬件加速提高仿真器性能 (Hyper-V & HAXM)】

1. 检查是否已安装 HAXM:

替换成自己的 Android SDK 路径

 -accel-check

我是如下结果,表示没有安装:

HAXM is not installed on this machine (/dev/HAX is missing).
2. 然后就是去下载最新的适用压缩包:[Intel 网站 HAXM 虚拟化引擎安装程序

](https://github.com/intel/haxm/releases)

3. 解压完我们可以看到这些文件:
haxm-macosx_v7_7_0
4. cd 到这个解压后的目录,执行:
sudo sh silent_install.sh

对了,在此之前可以先把 Android Studio 的 sdk 可更新的都更新了。

还有报警告或者仍然没解决的话:

 unexpected system image feature string, emulator might not function correctly, please try updating the emulator.

下面这个错 ❌ 就是在对应的目录找不到这两个文件:

~/Library/Android/sdk/emulator/qemu/darwin-x86_64/lib64/vulkan/libvulkan.dylib: failed
~/Library/Android/sdk/emulator/qemu/darwin-x86_64/lib64/vulkan/libMoltenVK.dylib: failed

其实这俩文件存在于~/Library/Android/sdk/emulator/lib64/vulkan/

那么我们 open sdk 所在目录,然后找到这个vulkan/目录,直接把它整个拷贝到 ~/Library/Android/sdk/emulator/qemu/darwin-x86_64/lib64/vulkan/下即可。

参考链接:
https://stackoverflow.com/questions/66455173/android-emulator-30-4-5-not-working-on-macos

https://stackoverflow.com/questions/65818831/android-studio-avd-causes-avd-to-crash-and-as-closes-without-warning

你可能感兴趣的:(MacOS Android Studio 启动模拟器报错:feature check for hvf)