Android emulator error: x86 emulation currently requires hardware acceleration的解决方案

时间:2022-04-17 15:54:39

转载自: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!

*中查到是由于Intel x86 Emulator Accelerator(HAXM installer)没有下载安装。如下所示:

Android emulator error: x86 emulation currently requires hardware acceleration的解决方案

 

下载安装后还是出现同样错误:

>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界面如下图所示:

Android emulator error: x86 emulation currently requires hardware acceleration的解决方案
 

点击CPU,此时可以看到CPU中的Virtualization 处于Disabled状态。就是这个原因导致intelhaxm-android.exe安装失败。

Android emulator error: x86 emulation currently requires hardware acceleration的解决方案

 

 

三、如何开启Virtualization (VT-x)

1.重启电脑在开机之前按F2键,进入BIOS设置模式,如下图所示,点击BIOS Features,进入BIOS设置模式,此时可以看到Intel Virtualization Technology处于Disabled模式。

 Android emulator error: x86 emulation currently requires hardware acceleration的解决方案

 

2.双击Disabled,会弹出一个对话框,双击选择Enabled,此时Intel Virtualization Technology处于Enabled模式。

Android emulator error: x86 emulation currently requires hardware acceleration的解决方案

 

3.保存设置,点击右上角的Save&Exit,双击并选择Save&Exit Setup,在弹出的对话框选择Yes,完成保存,此后PC会启动。开机后打开speccy,此时可以看到CPU中的Virtualization 处于Enabled状态。

 Android emulator error: x86 emulation currently requires hardware acceleration的解决方案

 
Android emulator error: x86 emulation currently requires hardware acceleration的解决方案

 

 

 

 

 

 

 

 

至此Virtualization (VT-x)开启成功,intelhaxm-android.exe安装成功,问题得以解决。

 

四、解决RAM大小不匹配的问题
以上问题解决后,再次运行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 error: x86 emulation currently requires hardware acceleration的解决方案
 
至此,Android emulator 可以顺利运行。