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:

Visual Studio 2015 RC Emulator for Android doesn't 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

share|improve this question
    
error 3 = ERROR_PATH_NOT_FOUND. Do you see the VHD in "C:\Users\lacike\AppData\Local\Microsoft\VisualStudioEmulato‌​r\Android\Containers‌​\Local\Devices\vhd\5‌​_KitKat_(4.4)_XXHDPI‌​_Phone\"? – magicandre1981 Jul 24 '15 at 15:19
    
Yes, I do. That folder contains two files: image.version.txt and image.vhd – Ladislav Margai Jul 24 '15 at 16:56
    
What OS are you running? Is it Win10? If so, what build? – John Kemnetz Jul 25 '15 at 4:04
    
No, it isn't. I am using Windows 8.1 Enterprise 64-bit. – Ladislav Margai Jul 25 '15 at 7:49

15 Answers 15

up vote 52 down vote accepted

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

share|improve this answer
1  
I was running into the same problem and this did the trick. Please note the importance of step 4 (I had network sharing enabled on my Wi-Fi). I have now been able to pass the "Preparing virtual machine" step. Now "Launching the emulator" (OS is starting). This seems to be taking a while though... I hope I'm not going to get stuck here. – Gyum Fox Aug 4 '15 at 7:15
1  
FYI: the OS did fail to start (same as stackoverflow.com/questions/29547546/…). But as far as I'm concerned, your answer solves the original question. – Gyum Fox Aug 4 '15 at 7:20
1  
I deleted the .suo files underneath the .vs folder. After that my emulators worked and ripple worked – Brian Oct 28 '15 at 14:31
    
Worked perfect for me. Thanks – ShahiM Jan 24 '16 at 19:26
    
it fixed without step 4. – Nuri YILMAZ May 18 '16 at 16:20

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.
share|improve this answer
    
It could be a solution, but if you use WiFi as a primary connection to the internet, it brings a little discomfort for you. – Ladislav Margai Sep 22 '15 at 7:16

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"

share|improve this answer

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.

share|improve this answer
    
+1 I can confirm connection with VirtualBox: On my machine, VirtualBox VMs only start when hypervisorlaunchtype is set to off. VS emulators OTOH only start when hypervisorlaunchtype is set to auto :-/. – Andreas Huber Nov 23 '16 at 16:07

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.

share|improve this answer
    
Strange, when I run it from command prompt I get this error – Ladislav Margai Jul 25 '15 at 18:15
    
Mhmm, have you tried repairing/reinstalling the Android SDK's via the Visual Studio installer? Also I'm guessing you are using Visual Studio 2015 RTM? – Mark Hebden Jul 25 '15 at 18:37
    
Yes, I am using Visual Studio 2015 RTM, I tried to re-install whole Visual Studio 2015 with all components, but it didn't help. – Ladislav Margai Jul 26 '15 at 9:36
    
This helped identify my problem, which turned out to be a bad Hyper-V path. I moved my VMs to a different hard drive, but never updated the default paths in the Hyper-V Settings so it wasn't able to create any new Android emulator images. – Dan Dautrich Jul 7 '16 at 18:16

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.

share|improve this answer
    
This does not really answer the question. If you have a different question, you can ask it by clicking Ask Question. You can also add a bounty to draw more attention to this question once you have enough reputation. - From Review – xenteros Sep 6 '16 at 9:40
    
This does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post; instead, provide answers that don't require clarification from the asker. - From Review – agua from mars Sep 6 '16 at 10:29
    
Thanks it solved my problem of getting the message n error occured while creating "VS Emulator 5" KitKat (4.4) XXHDPI Phone' device I tried all other solutions in this thread but yours was the only one that worked – devc2 Sep 24 '16 at 10:34

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?

share|improve this answer
    
I agree. I used to disable the Ethernet Connection leaving just the WiFi connectiong before creating the first VM device to get it working. Yesterday just upgraded to Windows 10.0.14372 I notice a new network device for Wireless Hosted Network (they say it is a Windows 7 feature but I don't remember seeing it before) - stopping the service and uninstall the device from Device Manager helped things move along instead of failing at creating the virtual switch. I will try this again a few times and find where to report it to Microsoft. msdn.microsoft.com/en-us/library/dd815243(VS.85).aspx – Dan Dar3 Jun 30 '16 at 11:00
1  
@DanDar3, thanks for the added info. I also didn't think of reporting to Microsoft; perhaps it's something they can address for all of us. – Eniola Jul 1 '16 at 6:23

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.

share|improve this answer

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!

share|improve this answer

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:)

share|improve this answer
    
This seems like a very heavy-handed approach... – Jarrod Mosen Sep 9 '16 at 3:57

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.

share|improve this answer

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

share|improve this answer

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

share|improve this answer

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

2) 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.

share|improve this answer

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.