Visual studio (2015) emulator for android not work

2019-01-03 14:20发布

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

16条回答
Melony?
2楼-- · 2019-01-03 14:51

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.

查看更多
我命由我不由天
3楼-- · 2019-01-03 14:51

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

查看更多
聊天终结者
4楼-- · 2019-01-03 14:52

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.
查看更多
做个烂人
5楼-- · 2019-01-03 14:53

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.

查看更多
Viruses.
6楼-- · 2019-01-03 14:54

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.

查看更多
做个烂人
7楼-- · 2019-01-03 14:54

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!

查看更多
登录 后发表回答