1. 问题描述
在Windows环境下Android Studio 1.2.2中运行时,出现下面错误信息:
emulator: WARNING: Classic qemu does not support SMP. The hw.cpu.ncore option from your config file is ignored.
HAXM is working and emulator runs in fast virt mode
什么是HAXM呢?它是Intel Hardware Accelerated Execution Manager (Intel® HAXM) 缩写,是Intel为了在开发主机上模拟Android app运行,使用虚拟化技术推出的一种利用硬件来辅助虚拟化的引擎。
在[1]中Android Studio安装过程中, HAXM缺省设置占用的内存为512MB。根据[4], 由于Nexus 5 AVD占用内存设置为1536MB,超过了HAXM的内存,因此模拟器无法正常运行。即AVD占用内存不能高于HAXM分配内存。 但是改变HAXM内存只能重装。
2.1 通过Android SDK Manager下载HAXM
参照[5], 点击Android SDK Manager, 在Extras中勾选"Intel x86 Emulator Accelerator (HAXM)."。
然后点击"Install package…"按钮开始安装HAXM,选择Accept后开始安装。
当安装完成后,出现安装成功日志:
但实际上,这里只是HAXM包下载到了extras/intel目录下,还需要手动来安装。
2.2 手动安装HAXM
双击"intelhaxm-android.exe"文件开始安装,首先出现下面欢迎窗口:
由于在[1]中已经安装过HAXM, 所以这里出现了Change, Repair和Remove的选项,这里选择Change按钮。
这里采用系统推荐的缺省值2GB,然后继续下一步:
然后点击“Change”按钮开始修改原来的设置。
如果要修改Intel HAXM内存,需要重新运行HAXM Installer。
再次运行原来的程序,可看出HAX正常运行:
emulator: device fd:17596
HAX is working and emulator runs in fast virt mode
emulator: warning: opening audio input failed
creating window 61 83 462 820
emulator: emulator window was out of view and was recentered
而且应用程序出现在了这个虚拟手机界面上,至此问题解决。
3. 参考资料
[1] Windows环境下Android Studio V1.2.2系列1—下载与安装, http://my.oschina.net/1pei/blog/467210
[2] Windows环境下Android Studio V1.2.2系列2—初次运行, http://my.oschina.net/1pei/blog/467736
[3] Intel® Hardware Accelerated Execution Manager, https://software.intel.com/en-us/android/articles/intel-hardware-accelerated-execution-manager
[4] How to fix: “HAX is not working and emulator runs in emulation mode, http://*.com/questions/21031903/how-to-fix-hax-is-not-working-and-emulator-runs-in-emulation-mode
[5] Installation Instructions for Intel® Hardware Accelerated Execution Manager - Microsoft Windows*, https://software.intel.com/en-us/android/articles/installation-instructions-for-intel-hardware-accelerated-execution-manager-windows