I was using Microsoft's Visual Studio Emulator for Android for some time. It is much more performant, at least on Windows 10, when compared to Google's own AVD emulators. When it works that is.
The netowork adapter tends to be a little finicky which would be a tad troublesome when you need to connect to an endpoint to pull data.
The problem seems to be induced when the following occurs:
- Installing a new version of Windows Phone emulators.
- Installing of a VPN client that creates its own adapter.
- Creation of new Virtual Adapters. This includes but are note limited to:
i. Virtual Box Adapters.
ii. Bridged adapters that are created by the user and not by Hyper-V or any other Microsoft emulation tool.
Cést la vie when it comes to Microsoft products. Always great until you delve in deep.
However, as with all problems, with proper application of one's mental faculties, we can always find some jiggery pokery to extricate from any problem, in this case needing a performant emulator that can't seem to connect to the internet.
What worked for me is as follows:
- Delete all Android emulators via the trash can icon in the Visual Studio for Android emulator control panel.
- Repair the installation of Visual Studio Emulator for Android. Do this via the following steps:
i. Go to Control Panel
ii. Go to Programs & Features
iii. Search for Android Emulators for Visual Studio.
iv. Click on 'Change'.
v. Click on 'Repair'.
- Go to Hyper-V Manager and delete all virtual switches. This may take awhile.
- Run XDECleanup, the directory for me is C:\Program Files (x86)\Microsoft XDE\10.0.10240.0.
- Clean up network bridges via the following steps:
i. Go to Control Panel.
ii. Go to Network & Sharing Centre.
iii. Open Network Connections.
iv. Add Bridge (curiously, this option only appears when there is an issue, if this option is not there, got straight to Step 6.)
v. With the bridge added, remove it to ensure all old network bridges are removed. This may take awhile.
- Now go to Visual Studio and fire up the Android Emulators for Android control panel and download your emulator of choice.
- Use the emulator :)
Alright, this should solve the biggest issue. However, in the advent if you have multiple network adapters or more specifically more than 2 (WiFi and Cable) which you would if you have VPN connections and so forth, there is a chance that it may pick the wrong adapters. DO NOT perform the following steps without testing the network of the emulators first. If it works, DO NOT perform the following steps.
To overcome this, do the following:
- Go to Hyper-V manager.
- Right click the emulator of interest.
- Go to Properties.
Now you will see lots of hardware properties. There should be something called 'Network Switches'. The first one should be the internal one, DO NOT touch that one, if you do, you are in for a world of hurt. The one that is of interest is the SECOND one which should be an external adapter. In there, select the proper network adapter this virtual switch should be bound to. If you are actually using WiFi, select the correct WiFi adapter and all that.
Hope this helps.