用Intel HAXM加速Android Emulator

週末試玩了一下在Eclipse中使用ADT開發Android應用程序的環境,當然誠如大家都懂的那樣,Android Emulator模擬器啓動和運行的速度確實是比較慢的,也都“有口皆碑”了的,呵呵。當然,Intel去年開發並在Google Android官方網站發佈了一個對Android Emulator的驅動,大幅提升了在Intel x86平臺上Android Emulator的啓動和運行效率,從而提升Android應用程序開發者在使用Android模擬器開發程序時的效率。
在Windows、MacOS上使用HAXM (Hardware Accelerated Execution Manager) 來加速Android Emulator,在Linux平臺上直接使用KVM加速即可。據官方介紹,一般來說使用了HAXM或KVM,有5~10x的性能提高,我簡單看了下確實也有幾倍的提高。
HAXM必須要求有Intel硬件虛擬化的支持,一般在BIOS中可以設置。BTW,ThinkPad X230的BIOS中,居然是在Security選項中設置VT的。
可以通過Android SDK Manager那下載HAXM, 在 Package 列表的最下面就是要用到的 Intel HAXM 擴展 (Intel x86 Emulator Accelerator (HAXM)),也需要安裝對應的Image(Intel x86 Atom System Image)。下載後的HAXM安裝文件在sdk\extras\intel\Hardware_Accelerated_Execution_Manager 目錄下,點擊安裝即可(注意如果Intel VT沒有打開是不能安裝成功的)。

在製作AVD時,需要設置其“CPU/ABI”屬性爲“Intel Atom (x86)”。對於圖形方面的加速,編輯AVD設置時,Emulation Option選擇“Use Host GPU”。

Android Virtual Device Manager中啓動某個某個AVD時,可能會看到如下:

Starting emulator for AVD 'AVD_for_Nexus_S_by_Google'
emulator: device fd:620
HAX is working and emulator runs in fast virt mode
creating window 0 0 438 729

Eclipse中ADT運行時,對應的輸出如下(可以看到HAX是否work):

[2013-07-08 11:44:43 - JayFirstApp] ------------------------------
[2013-07-08 11:44:43 - JayFirstApp] Android Launch!
[2013-07-08 11:44:43 - JayFirstApp] adb is running normally.
[2013-07-08 11:44:43 - JayFirstApp] Performing com.example.jayfirstapp.MainActivity activity launch
[2013-07-08 11:44:43 - JayFirstApp] Automatic Target Mode: launching new emulator with compatible AVD 'AVD_for_Nexus_S_by_Google'
[2013-07-08 11:44:43 - JayFirstApp] Launching a new emulator with Virtual Device 'AVD_for_Nexus_S_by_Google'
[2013-07-08 11:44:47 - Emulator] emulator: device fd:620
[2013-07-08 11:44:47 - Emulator] 
[2013-07-08 11:44:47 - Emulator] HAX is working and emulator runs in fast virt mode
[2013-07-08 11:44:50 - Emulator] creating window 0 0 438 729
[2013-07-08 11:44:50 - JayFirstApp] New emulator found: emulator-5554
[2013-07-08 11:44:50 - JayFirstApp] Waiting for HOME ('android.process.acore') to be launched...


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章