在Windows环境下Android Studio 1.2.2中运行时,出现下面错误信息:android
HAX is not working and emulator runs in emulation mode
windows
emulator: The memory needed by this AVD exceeds the max specified in your HAXM configuration.app
emulator: AVD RAM size = 1536 MBthis
emulator: HAXM max RAM size = 512 MBspa
emulator: You might want to adjust your AVD RAM size and/or HAXM configuration to run in fast virt mode..net
在[2]中Android Studio初次运行过程当中,已经建立好了Android虚拟设备Nexus_5_API_22_x86, 但这个虚拟设备如今运行时出现了手机界面,可是其中什么也没有显示出来。日志
什么是HAXM呢?它是Intel Hardware Accelerated Execution Manager (Intel® HAXM) 缩写,是Intel为了在开发主机上模拟Android app运行,使用虚拟化技术推出的一种利用硬件来辅助虚拟化的引擎。orm
在[1]中Android Studio安装过程当中, HAXM缺省设置占用的内存为512MB。根据[4], 因为Nexus 5 AVD占用内存设置为1536MB,超过了HAXM的内存,所以模拟器没法正常运行。即AVD占用内存不能高于HAXM分配内存。 可是改变HAXM内存只能重装。blog
参照[5], 点击Android SDK Manager, 在Extras中勾选"Intel x86 Emulator Accelerator (HAXM)."。内存
而后点击"Install package…"按钮开始安装HAXM,选择Accept后开始安装。
当安装完成后,出现安装成功日志:
但实际上,这里只是HAXM包下载到了extras/intel目录下,还须要手动来安装。
双击"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
并且应用程序出如今了这个虚拟手机界面上,至此问题解决。
[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://stackoverflow.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