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条回答
劳资没心,怎么记你
2楼-- · 2019-01-03 14:54

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

查看更多
Fickle 薄情
3楼-- · 2019-01-03 14:55

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

查看更多
我只想做你的唯一
4楼-- · 2019-01-03 14:57

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.

查看更多
疯言疯语
5楼-- · 2019-01-03 14:58

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.

查看更多
登录 后发表回答