Visual Studio 2017/Android Development

I have Hyper-V installed, along with a few VM's. And I use Docker, regularly, so I know Hyper-V is installed and working.

I wanted to start my first real Android App. Created a new Android (Xamarin) project and hit play. I wanted to make sure my environment would work first so I hit play. I then got a message that said deployment failed. Ok, try running Visual Studio as Administrator. That worked better, I then got a Performance Warning saying


Launching the Android Emulator

Android_Accelerated_x86_Oreo on Hyper-V needs the Windows Hypervisor Platform installed and enabled.

Please configure it using the Turn Windows Features on or off dialog.


The thing is, I have Hyper-V installed, along with a few VM's. And I use Docker, regularly, so I know Hyper-V is installed and working. I found on docs.microsoft.com there is more than one Hyper-V component. I’ll call one magical because it may not actually be enabled, the HypervisorPlatform. I wonder if this was added after one of the big Windows Updates or something.

To make sure the required Hyper-V components are installed, run the following powershell commands from an elevated prompt

(Get-WindowsOptionalFeature -FeatureName Microsoft-Hyper-V-All -Online).State
(Get-WindowsOptionalFeature -FeatureName HypervisorPlatform -Online).State

If you already have Hyper-V installed (like me) and it works because you're already running vm's then I suspect the first command will return the state as Enabled. The second one however, returned a state of disabled.

C:\Windows\system32> (Get-WindowsOptionalFeature -FeatureName Microsoft-Hyper-V-All -Online).State
Enabled
C:\Windows\system32> (Get-WindowsOptionalFeature -FeatureName HypervisorPlatform -Online).State
Disabled

Interesting. Since the HypervisorPlatform is required, running Enable-WindowsOptionalFeature -Online -FeatureName HypervisorPlatform -All will install and enable it. For me, that command required a reboot. After the reboot, it worked correctly. What's interesting is everything in the Add or Remove Windows Features for Hyper-V was already turned on. I'll chalk it up to some random bug in Windows.

So, key take-aways:

  1. Run Visual Studio as Administrator for mobile development
  2. Verify all Hyper-V components are installed
    (Get-WindowsOptionalFeature -FeatureName Microsoft-Hyper-V-All -Online).State
    (Get-WindowsOptionalFeature -FeatureName HypervisorPlatform -Online).State
    
  3. Install missing Hyper-V components
    Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V-All -All
    Enable-WindowsOptionalFeature -Online -FeatureName HypervisorPlatform -All