在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