Visual studio (2015) emulator for android not working - XDE.exe - Exit Code 3

AndroidVisual StudioXamarinAndroid EmulatorVisual Studio-2015

Android Problem Overview


I have created a new Blank App (Xamarin.Forms Portable) project in Visual Studio 2015.

When I try to run Droid project in Visual Studio Emulator for Android, I just get a generic error message:

> An error occured while creating 'VS Emulator 5" KitKat (4.4) XXHDPI Phone' device.

So I looked into Tools->Visual Studio Emulator for Android, and tried to run emulator manually. After a while it fails and log says:

> 24.7.2015 16:22:52: [Informational] Reinitializing installed profiles.

> 24.7.2015 16:22:52: [Informational] Installed profiles initialized. Devices: 2 Platforms: 1

> 24.7.2015 16:22:52: [Informational] Reinitializing installable profiles.

> 24.7.2015 16:22:52: [Informational] Installable profiles initialized. Devices: 30 Platforms: 4

> 24.7.2015 16:22:56: [Informational] Waiting to launch device...

> 24.7.2015 16:22:56: [Informational] Launching Device: 5" KitKat (4.4) XXHDPI Phone

> 24.7.2015 16:22:56: [Informational] Validating emulator arguments...

> 24.7.2015 16:22:56: [Informational] Determining if emulator is already running...

> 24.7.2015 16:22:56: [Informational] Preparing virtual machine...

> 24.7.2015 16:22:58: [Critical] An error occured while creating 'VS Emulator 5" KitKat (4.4) XXHDPI Phone' device.

> 24.7.2015 16:22:58: [Critical] XDE Path: C:\Program Files (x86)\Microsoft XDE\10.0.10240.0\xde.exe

> 24.7.2015 16:22:58: [Critical] XDE Arguments: /sku Android /displayName "VS Emulator 5" KitKat (4.4) XXHDPI Phone" /memSize 2048 /diagonalSize 5 /video "1080x1920" /vhd "C:\Users\lacike\AppData\Local\Microsoft\VisualStudioEmulator\Android\Containers\Local\Devices\vhd\5_KitKat_(4.4)_XXHDPI_Phone\image.vhd" /name "VS Emulator 5-inch KitKat (4.4) XXHDPI Phone.lacike" /noStart /silent

> 24.7.2015 16:22:58: [Critical] XDE Exit Code: 3

However when I run WinPhone project in Windows Phone emulator, it works. It uses XDE.exe like Android Emulator, so Hyper-V network is working.

Any ideas?

UPDATE:

When I tried to install a new device profile, I run to this same issue:

https://stackoverflow.com/questions/30238963/visual-studio-2015-rc-emulator-for-android-doesnt-start

The process is stuck on "Copying .vhd files and creating virtual machine".

UPDATE 2:

When I open a command prompt and then run xde.exe with following xde arguments:

> xde.exe /sku Android /displayName "VS Emulator 5" KitKat (4.4) XXHDPI Phone" /memSize 2048 /diagonalSize 5 /video "1080x1920" /vhd "C:\Users\lacike\AppData\Local\Microsoft\VisualStudioEmulator\Android\Containers\Local\Devices\vhd\5_KitKat_(4.4)_XXHDPI_Phone\image.vhd" /name "VS Emulator 5-inch KitKat (4.4) XXHDPI Phone.lacike

I get following error:Service Host Error

Android Solutions


Solution 1 - Android

After hours and hours of research, and applying following steps I finally get it working:

> 1) Repair Android SDK - go to Programs and Features > Microsoft Visual > Studio Emulator for Android > Change and hit "Repair" > > 2) Remove All Hyper-V virtual switches - go to Hyper-V > Virtual > switch manager > Remove all virtual switches > > 3) Run XdeCleanup.exe - In my case: "C:\Program Files (x86)\Microsoft > XDE\10.0.10240.0" > > 4) In my case I had configured Internet connection sharing on Ethernet adapter before so I > had to disable it

Solution 2 - Android

Usually, the System.ServiceModel.ServiceHost error means there is some residue from a botched installation.

First, go to Task Manager and kill any running XDE processes. If that doesn't fix it, go to Programs and Features > Microsoft Visual Studio Emulator for Android > Change and hit "Repair"

Solution 3 - Android

I have found the following to work for me:

  1. Disable your WiFi connection.
  2. Launch your app.
  3. Observe Emulator gets loaded
  4. Re-enable WiFi.
  5. Note how restarting your app should not be an issue anymore as long as the emulator is initially loaded.

Solution 4 - Android

I ran into the same problem. However, I have managed to get the emulator running by doing the following. Browse to the xde.exe directory and open a command prompt then run xde.exe with the xde arguments in your log minus the /nostart /silent commands. So in your case:

> xde.exe /sku Android /displayName "VS Emulator 5" KitKat (4.4) XXHDPI > Phone" /memSize 2048 /diagonalSize 5 /video "1080x1920" /vhd > "C:\Users\lacike\AppData\Local\Microsoft\VisualStudioEmulator\Android\Containers\Local\Devices\vhd\5_KitKat_(4.4)_XXHDPI_Phone\image.vhd" > /name "VS Emulator 5-inch KitKat (4.4) XXHDPI Phone.lacike"

It's probably also worth opening task manager first and end all running xde.exe processes first.

However I don't have Xamarin, so I'm not able to confirm that this will then let you deploy to the emulator.

Solution 5 - Android

Just thought I'd add the solution that solved my problem.

After some digging around I realized that, for some reason, Hypervisor wasn't started with my computer. I have an vague feeling that the VirtualBox setup might be responsible for this, but that is not confirmed.

Anyhow, for me the solution was to enable hypervisor startup at boot time using BCDEDIT.

In an admin console enter:

BCDEDIT /Set {current} hypervisorlaunchtype auto 

and restart the computer.

Solution 6 - Android

I did this and my problem was fixed

  • Start cmd.exe with Admin rights and type

  • bcdedit /set hypervisorlaunchtype auto

  • Restart pc.

  • run as administrator visual studio.

Good luck!

Solution 7 - Android

I had the same problem after installing Android Studio.

Android Studio needs "bcdedit /set hypervisorlaunchtype off"

Visual Studio Emulator for Android needs "bcdedit /set hypervisorlaunchtype auto"

Because of that, I switch to "off" or "auto" and reboot my system.

Solution 8 - Android

I think the root cause of the problem varies from machine to machine but seems to have something to do with how the Device Drivers of various network interfaces interact with the HyperV system (by the way, I am running Windows 10; some things are bound to be slightly different than Windows 8).

I have a MiFi device that draws power from my laptop's USB port. The device can allow direct connection to it over USB by the host system. When disconnected from the USB port, it routes traffic over WiFi.

@Ladislav's steps were a good starting point for me. It took a lot of monkeying around - after deleting all Emulator Images and Virtual Switches, then repairing the Emulator for Android installation - I stumbled on the likely cause of my problem being the MiFi unit.

I tried different configurations and noticed that if you disable the Ethernet Connection created automatically by windows (it has a description of Remote NDIS based Internet Sharing Device), the Emulators - Android and WindowsPhone now agree to start.

I plan to do more digging but I noticed that HyperV automatically creates virtual switches for all Bluetooth, WiFi and the main Ethernet port but not for the MiFi USB connection. Perhaps that creates some confusion in the underlying HyperV system and getting it out of the way makes everything run fine.

Perhaps others can also share their findings?

Solution 9 - Android

I had this problem, removal of virtual switches in Hyper V was not enough. To resolve it I needed to turn off and then turned back on Hyper V itself.

Solution 10 - Android

I faced the same issue for a week. i followed below steps to fix this,

  1. Reset your PC.It will clear all your data and installation file and restore the OS to earlier stage Reset PC
  2. Reinstall the visual studio emulator for android
  3. Start any profile and it works emulator

Good Luck:)

Solution 11 - Android

After formatting my computer I faced the same issue.

The issue was fixed by updating my LAN card drivers, although I don't know why that is.

Solution 12 - Android

I encountered the same problem. It has manifested itself ever since I upgraded to Windows 10 (regardless of the build).

None of the solution stated above seemed to work. However, after deactivating all but one of my network interfaces (I have three : Ethernet x 2 and Wifi), the solution proposed by Ladislav Margai above just worked.

This is what i've done :

>1) Repair Android SDK - go to Programs and Features > Microsoft Visual Studio Emulator for Android > Change and hit "Repair"

>2) Remove All Hyper-V virtual switches - go to Hyper-V > Virtual switch manager Remove all virtual switches

>3) Run XdeCleanup.exe - In my case: "C:\Program Files (x86)\Microsoft XDE\10.0.10240.0"

>3 bis) Deactivate all but one of your network interface

>4) Launch Android emulator for VS with administrator privileges

>5) Activate your network interfaces back

Solution 13 - Android

I solved the problem simply by running the VS Android Emulator as an admin.

Running Visual Studio as an admin also solved instant crashes that I had on every start.

Solution 14 - Android

I had the same problem to solve it I followed the different step as recommended but nothing, and at the end I simply copied the name of the emulator appears in error message in the log file and following the path to open the .cfg C:\Users\lacike\AppData\Local\Microsoft\VisualStudioEmulator\Android\Containers\Local\Devices\vhd\5_KitKat_(4.4)_XXHDPI_Phone and paste this name before device.name

Solution 15 - Android

I had hard times setting this up, but after a couple of days of R&D and trying with other people answers I could got this done. Hurray!!!

  1. Issue 1: My Visual Studio 2015 Community Edition was halting at 'Preparing virtual machine'. Solution:
  • After analysis I saw that in my VS -> Tools -> Android -> Android Emulator Manager, my AVD (AVD_GalaxyNexus_ToolsForApacheCordova) was showing a res cross(x). - I corrected this by installing this. This is because my emulator device is: VS Emulator 5-inch KitKat (4.4) XXHDPI Phone for API-19. enter image description here
  1. Issue 2: It passed the 'Preparing virtual machine' step, but I faces numerous network creation issue. Solution: This was resolved under the following situation. The emulator always created the virtual switch using my ethernet while I was connected by wifi. So, I switched to a LAN cable provided internet and temporarily disabled my wifi.

Then it was a success. I needed to do the steps mentioned by Ladislav Margai several times in between.

I hope it might help others.

Solution 16 - Android

I tried a bunch of the steps here and they didn't work, so I stepped through this in-depth troubleshooter from Microsoft and found the problem.

https://msdn.microsoft.com/library/windows/apps/jj863509(v=vs.105).aspx

In my case, while Hyper-V had been installed, the Hyper-V Hypervisor (under Hyper-V Platform) had not been installed.

I installed it, re-started, and suddenly the issue was resolved. Can't believe I overlooked it - but maybe someone else has overlooked it too and this helps! :D

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionLadislav MargaiView Question on Stackoverflow
Solution 1 - AndroidLadislav MargaiView Answer on Stackoverflow
Solution 2 - AndroidJohn KemnetzView Answer on Stackoverflow
Solution 3 - AndroidScott NimrodView Answer on Stackoverflow
Solution 4 - AndroidMark HebdenView Answer on Stackoverflow
Solution 5 - AndroidFishySwedeView Answer on Stackoverflow
Solution 6 - Androiduser5785619View Answer on Stackoverflow
Solution 7 - Androiduser6797902View Answer on Stackoverflow
Solution 8 - AndroidEniolaView Answer on Stackoverflow
Solution 9 - AndroidFroggerView Answer on Stackoverflow
Solution 10 - AndroidthangaduraiView Answer on Stackoverflow
Solution 11 - AndroidNam-gyu JeonView Answer on Stackoverflow
Solution 12 - AndroidMathieu A. DerbanneView Answer on Stackoverflow
Solution 13 - AndroidwinbosView Answer on Stackoverflow
Solution 14 - AndroidserenityView Answer on Stackoverflow
Solution 15 - Androidbikram s.View Answer on Stackoverflow
Solution 16 - AndroidBleak MornView Answer on Stackoverflow