Microsoft needs to fix its Android emulator

Microsoft wants Windows 10 to be an ideal developer operating system, with its Linux subsystem, and Visual Studio 2017 is notable for its strong cross-platform development tools.

There is an annoyance though. Google’s Android SDK includes an emulator for debugging mobile applications, but it requires hardware acceleration in the form of Intel’s HAXM (Hardware Accelerated Execution Manager). Otherwise you get an error as below:

image

Unfortunately this is incompatible with Hyper-V, the hypervisor built into Windows. You cannot fix this by stopping Hyper-V services; it is set when Windows boots.

Hyper-V is increasingly important for general Windows developers. It is not only useful for running up VMs on which to test stuff, but also for the official Docker tools and testing Windows containers.

The solution should be to use the Visual Studio Emulator for Android. This is based on Hyper-V so no problem.

Unfortunately it does not currently work very well. On one of my PCs it starts, but without internet connectivity, rendering it useless for many apps. On another PC it does not start at all.

image

I spent a bit of time trying to get it to work. The networking problem seems to be related to conflicts with other applications using Hyper-V. Specifically, the Visual Studio Emulator for Android uses two Hyper-V virtual network adapters, one connected to the Windows Phone Emulator Internal Switch, and the other connected to an external virtual switch. This second adapter gets its network settings using DHCP (there is no way to change this). The emulator app proxies internet connections from the internal to the external network.

The reference to Windows Phone comes about because this is essentially the Windows Phone emulator adapted to run Android.

In my Hyper-V setup I have another internal switch, called DockerNAT, used by the Docker tools, as well as a third internal switch which I’ve used for other things. In the emulator’s network settings I can actually see four Desktop Adapters (in addition to the primary “Emulator adapter”, of which only one has internet connectivity via my business network. I theorised that the emulator is attempting to proxy via the wrong adapter, and disabled the others in Control Panel – Network Connections. However it still does not connect.

Judging by posts like this and this, there may be some cocktail of settings in Hyper-V and in Control Panel that gets this working. Bear in mind though that I want everything else to work too.

I also note that Windows developer evangelist Scott Hanselman suggests setting up a dual boot arrangement so that you can boot with HAXM enabled when you want to develop on Android, and with Hyper-V otherwise – implying that there is no other easy fix.

This works, though it is a dreadful solution. Rebooting is not only time-consuming, but disruptive to the flow of your work, and having to reboot with special settings just to work on Android is painful.

It strikes me that this could be fixed with a bit of effort. If Microsoft is serious about persuading developers to use Windows 10, Visual Studio and Xamarin for cross-platform mobile apps, that would be a good idea.

6 thoughts on “Microsoft needs to fix its Android emulator”

  1. I have never had any issue with Microsoft android emulator and quite foreign to your problems, never seen any of them actually and I run win10 on stable and fast rings. It is much faster than the Google one (now, as today, google’s is better though, but..). As I have not seen them, I suspect the problem is some combination of things on your computer.

    That said, fast ring at the moment is slightly unstable as an OS.

    The biggest issue with the Microsoft emulator (and any non google) has more been that it is rather tedious to get Google play to work however, this is though probably slightly out of Microsoft’s hands.

    Hanselman’s suggestion is from before you had the emulator and before windows 10. I have the same setup, but this is because of virtual box not really because of any issue with Hyper-V

  2. @Ben thanks for the tip. Unfortunately in my case it didn’t help. On PC A it runs but without internet connectivity. On PC B it hangs for ages on “OS is starting”, then gives an error “Couldn’t auto-detect the guest IP address.” DCHP is used everywhere so it is not that.

    Tim

  3. Tim, experiencede similar issues, but have finally moved on a bit after some experimentation and finally (today) having done the following:
    After installing VS2017 (using the options needed for Xamarin challenge), started the Android SDK Manager (run As Administrator) and updated everything before going any further.
    Then after loading the Xamarin Challenge part 1, the build worked for the first time since trying.
    On the first run of the modified build (step 18) I got a request to elevate the Android emulator due to HyperV issues, and it all worked.
    Up to this point the Xamarin project failed event to build on 2 different machines.
    One machine is 1607 fully patched, the other 1703 (likewise). It’s worked on the 1607 build.

    I guess, as ever with windows machines, YMMV

Comments are closed.