轉載自:http://qa.blog.163.com/blog/static/190147002201561264746235
一、問題描述
在自學android過程中遇到一個問題:
安裝配置好android studio,新建了一個簡單的應用后,想啟動AVD,運行Android emulator時出現了如下的錯誤:
>emulator: ERROR: x86 emulation currently requires hardware acceleration! >Please ensure Intel HAXM is properly installed and usable. >CPU acceleration status: HAX kernel module is not installed!
在stackoverflow中查到是由於Intel x86 Emulator Accelerator(HAXM installer)沒有下載安裝。如下所示:
![]()
下載安裝后還是出現同樣錯誤:
>emulator: ERROR: x86 emulation currently requires hardware acceleration! >Please ensure Intel HAXM is properly installed and usable. >CPU acceleration status: HAX kernel module is not installed!
進一步找到原因是:沒有安裝intelhaxm-android.exe,所在目錄為:
{SDK_FOLDER}\extras\intel\Hardware_Accelerated_Execution_Manager\ intelhaxm-android.exe。
當在安裝intelhaxm-android.exe過程中出現錯誤:Virtualization (VT-x)沒有開啟,安裝intelhaxm-android.exe失敗的提示信息。最終費勁周折才找到,需要到PC BIOS設置模式下才能開啟VT-x。
二、軟件Speccy介紹
為了查看本機Virtualization (VT-x)是否開啟可以通過軟件speccy進行查看,軟件speccy下載地址為:http://filehippo.com/zh/download_speccy/
安裝speccy,打開speccy界面如下圖所示:
![]()
點擊CPU,此時可以看到CPU中的Virtualization 處於Disabled狀態。就是這個原因導致intelhaxm-android.exe安裝失敗。
![]()
三、如何開啟Virtualization (VT-x)
1.重啟電腦在開機之前按F2鍵,進入BIOS設置模式,如下圖所示,點擊BIOS Features,進入BIOS設置模式,此時可以看到Intel Virtualization Technology處於Disabled模式。
2.雙擊Disabled,會彈出一個對話框,雙擊選擇Enabled,此時Intel Virtualization Technology處於Enabled模式。
![]()
3.保存設置,點擊右上角的Save&Exit,雙擊並選擇Save&Exit Setup,在彈出的對話框選擇Yes,完成保存,此后PC會啟動。開機后打開speccy,此時可以看到CPU中的Virtualization 處於Enabled狀態。
![]()
至此Virtualization (VT-x)開啟成功,intelhaxm-android.exe安裝成功,問題得以解決。
以上問題解決后,再次運行emulator,出現如下錯誤:HAX is not working and emulator runs in emulation mode
emulator: device fd:760
emulator: The memory needed by this AVD exceeds the max specified in your HAXM configuration.
emulator: AVD RAM size = 1536 MB
emulator: HAXM max RAM size = 1024 MB
emulator: You might want to adjust your AVD RAM size and/or HAXM configuration to run 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可以看到emulator: AVD:RAM size = 1536 MB,emulator: HAXM max RAM size = 1024 MB,RAM大小不匹配。解決方案:重新安裝 intelhaxm-android.exe,將RAM改為1536 即可。如下圖所示:
至此,Android emulator 可以順利運行。