Menu

Using Visual Studio’s Android Emulator alongside Hyper-V

21st July 2019 - Uncategorised

Any Microsoft developer soon notices a chasm when they stray into the Android development world. And that chasm is between Hyper-V and the Android Studio Emulator. This exists because you cannot have two hardware based virtualisation platforms running at the same time.

So, in the not too distant past, the only option was to disable Hyper-V, restart and ne-er the twain shall meet. And for those of us who use Hyper-V for docker and virtual lab testing, its a pain.

Since Visual studio v15.8 however, this has changed. You still need at least Windows 10 April 2018/1803/build 17134.1 too, but if you’re up to date with Visual Studio you’ve usually got Windows 10 fairly up to date.

I’ll be using Visual Studio 2019.

In Visual Studio, as part of the xamarin integration, under Tools in the main menu there is an option for Android.

Open up the Android SDK manager, and ensure you install the Android SDK Tools is greater than 26.1 and the Android Emulator is greater than 27.2.7

Check you have plenty of space on whatever drive you have installed visual studio on, as the android images often approach and exceed 1GB in size.

Once everything is installed, go back to the Android menu under tools and select the Android Device Manager

Click Add and select the Pixel under x86 (HyperV acceleration will only emulate x86).

Run your newly created image and you’ll see its working nicely alongside your Hyper-V images.

Hopefully, this should all work peachy. try the troubleshooting below if you have any problems.

Take Care

Troubleshooting

If you get a WPHX error, try the following

Check for acceleration compatibility

Open powershell and navigate to the following location

C:\Program Files (x86)\Android\android-sdk\emulator

Run the android check tool

.\emulator-check.exe accel

And you’ll get some idea of any immediate problem.

accel:
0
HAXM is not installed, but Windows Hypervisor Platform is available.
accel

Verify Hyper-V

Firstly check that hypervisor is installed via Windows Features.
Hyper-V Management Tools, Hyper-V platform, plus, and most people miss this, Windows Hypervisor Platform

If you still have issue after enabling these, hop into powershell.

Get-WindowsOptionalFeature -FeatureName Microsoft-Hyper-V-All -Online

If not installed, install Hyper-V via powershell

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All
Enable-WindowsOptionalFeature -Online -FeatureName HypervisorPlatform -All

If in doubt..

reboot

Leave a Reply