Android Emulator hypervisor driver安装失败解决
朋友,当你看到这篇文章,相信之前也搜索过很多解决博客,也相信了其他大佬说法,是因为电脑CPU不同或硬件环境导致的,最终还得看官方解释。
一、电脑环境和安装地址
github安装链接
电脑安装条件:
1、CPU 具有虚拟化扩展,并且 BIOS 尚未禁用该扩展。(CPU开启虚拟化,任务管理器可以看到,如下图)
2、必须禁用 Hyper-V。 (命令提示符关闭,以管理员身份运行命令提示符,执行命令:
bcdedit /set hypervisorlaunchtype off)
二、勾选Android Emulator hypervisor driver,进行安装:
安装后会报错,同时在{android-sdk}\extras\google\Android_Emulator_Hypervisor_Driver目录下安装文件silent_install.bat 等。
三、在{android-sdk}\extras\google\Android_Emulator_Hypervisor_Driver目录下执行silent_install.bat,报错同步骤二。
解决步骤如下:
1、首先参考了文章:https://blog.csdn.net/qq_37242224/article/details/107625180
安装了工具检测,对我解决问题也没有啥用,
2、然后参考文章:https://blog.csdn.net/gonghui_gonghui/article/details/136069862
这篇文章还是有作用的,主要是把{android-sdk}\extras\google\Android_Emulator_Hypervisor_Driver
文件夹下的silent_install.bat 内容用以下代码替换掉:
@echo off
:-------------------------------------
Check for admin rights
fltmc >nul 2>&1
if %errorlevel% NEQ 0 (
echo Requesting administrative privileges...
goto getAdmin
)
:gotAdmin
pushd "%CD%"
CD /D "%~dp0"
:--------------------------------------
Parse commands
set action=install
:parseInput
if "%~1"=="" (
goto %action%
)
if /i "%~1"=="-u" (
set action=uninstall
shift
goto parseInput
)
if /i "%~1"=="-v" (
set action=checkinstall
shift
goto parseInput
)
REM Ignore other params
shift
goto parseInput
:getAdmin
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
if '%errorlevel%' NEQ '0' (
echo Requesting administrative privileges...
goto UACPrompt
) else ( goto gotAdmin )
:UACPrompt
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
echo UAC.ShellExecute "cmd.exe", "/c %~s0 %*", "", "runas", 1 >> "%temp%\getadmin.vbs"
"%temp%\getadmin.vbs"
del "%temp%\getadmin.vbs"
exit /B
:install
sc query gvm >nul 2>&1
if %errorlevel% EQU 0 (
sc stop gvm
sc delete gvm
)
RUNDLL32.EXE SETUPAPI.DLL,InstallHinfSection DefaultInstall 132 .\gvm.inf
if %errorlevel% NEQ 0 (
echo Failed to install GVM
exit /b 1
)
sc start gvm
exit /b 0
:uninstall
sc query gvm >nul 2>&1
if %errorlevel% NEQ 0 exit /b 0
sc stop gvm
sc delete gvm
if %errorlevel% NEQ 0 (
echo Failed to uninstall GVM
exit /b 1
)
exit /b 0
:checkinstall
sc query gvm >nul 2>&1
if %errorlevel% EQU 0 (
exit /b 0
) else (
exit /b 1
)
3、替换完后,在Check for admin rights、 Parse commands前添加REM,如下:
REM Check for admin rights
REM Parse commands
然后再运行silent_install.bat 。
4、相信有的朋友还是会报错,别急,可能你的CPU没有大问题。
下面请看Android Studio官方解释:
相信看到这就知道了,要保持版本跟服务名称一致,所以请注意看上面图中,即下图对应的版本是2.2.0
所以要在silent_install.bat里把所有的“gvm”改为“”aehd“,然后再运行silent_install.bat,相信到这步,很多朋友就会看到成功的曙光了。
silent_install.bat经过替换、添加、替换“gvm”->“aehd”,完整的替换代码如下:
@echo off
:-------------------------------------
REM Check for admin rights
fltmc >nul 2>&1
if %errorlevel% NEQ 0 (
echo Requesting administrative privileges...
goto getAdmin
)
:gotAdmin
pushd "%CD%"
CD /D "%~dp0"
:--------------------------------------
REM Parse commands
set action=install
:parseInput
if "%~1"=="" (
goto %action%
)
if /i "%~1"=="-u" (
set action=uninstall
shift
goto parseInput
)
if /i "%~1"=="-v" (
set action=checkinstall
shift
goto parseInput
)
REM Ignore other params
shift
goto parseInput
:getAdmin
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
if '%errorlevel%' NEQ '0' (
echo Requesting administrative privileges...
goto UACPrompt
) else ( goto gotAdmin )
:UACPrompt
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
echo UAC.ShellExecute "cmd.exe", "/c %~s0 %*", "", "runas", 1 >> "%temp%\getadmin.vbs"
"%temp%\getadmin.vbs"
del "%temp%\getadmin.vbs"
exit /B
:install
sc query aehd >nul 2>&1
if %errorlevel% EQU 0 (
sc stop aehd
sc delete aehd
)
RUNDLL32.EXE SETUPAPI.DLL,InstallHinfSection DefaultInstall 132 .\aehd.inf
if %errorlevel% NEQ 0 (
echo Failed to install aehd
exit /b 1
)
sc start aehd
exit /b 0
:uninstall
sc query aehd >nul 2>&1
if %errorlevel% NEQ 0 exit /b 0
sc stop aehd
sc delete aehd
if %errorlevel% NEQ 0 (
echo Failed to uninstall aehd
exit /b 1
)
exit /b 0
:checkinstall
sc query aehd >nul 2>&1
if %errorlevel% EQU 0 (
exit /b 0
) else (
exit /b 1
)
原文参考:
https://blog.csdn.net/gonghui_gonghui/article/details/136069862
https://github.com/google/android-emulator-hypervisor-driver/issues/88
https://blog.csdn.net/qq_37242224/article/details/107625180
https://developer.android.google.cn/studio/run/emulator-acceleration.html?hl=el