Xamarin Android Emulator Setup in Visual Studio 2017

with Visual Studio Emulator for Android

November 15, 2017 Xamarin, Visual Studio, C#, Mobile, Android

I've recently started to learn Xamarin to build any mobile app with C# because I've mainly used C# for programming. The concept of Xamarin which is "write-once, run everywhere" seemed quite attractive so I decided to learn it.

What I had to do at first is to set up Xamarin development environment. I chose a Visual Studio 2017 community version. For iOS deployment, I have to use either an iMac or a Macbook. As I only have Windows environment, so I decided to go with android first and try out the Xamarin Live Player app for iOS deployment. The live player function enables developers to deploy iOS apps to their actual iPhones via the live player app. _(* This feature has changed to test apps on Android devices. For iOS, Mac host is still needed..[Link](https://docs.microsoft.com/en-us/xamarin/tools/live-player/))_

To install the Visual Studio 2017 was easy as well as Xamarin development tools. I could choose whatever tools I want to install on the workload while installing.

Visual Studio Installer Workloads View Visual Studio Installer Workloads View

The problem was when I tried to deploy an Android project to an emulator. I found out that there are two types of emulators. One is using Android SDK and another is using Visual Studio Emulator for Android. After taking a closer look on them, I found out that Visual Studio Emulator for Android is much faster than Android SDK so I installed it through Visual Studio installer again. _(* Versions after Marshmallow are not supported on this emulator and the website recommends Google emulator for the latest verions instead. [Link](https://visualstudio.microsoft.com/vs/msft-android-emulator/))_ You can select it to install in the Individual components > Emulators menu.

Visual Studio Installer Individual components View Choose Visual Studio Emulator for Android under Emulators if it is not selected.

I installed that emulator on my computer and tried to deploy again. But this time, I couldn’t see anything running on the emulator although everything looked fine.

Debugging running view Everything seems fine.

So I googled what went wrong and finally reached this page.

https://forums.xamarin.com/discussion/62307/xamarin-android-projects-failed-to-deploy-in-visual-studio-emulator-for-android

My case came under both the CPU compatibility and the registry.

My CPU was Intel i7-6600U and its code name is SkyLake and this CPU has an issue with Hyper-V that the Visual Studio Emulator for Android depends on. In order to sort this out, I followed this step.

  1. Open the Hyper-V Manager and go to settings of the virtual device.
  2. Hyper-V Manager main view Right-click on the emulator you want to set up and choose settings.
  3. Check off “Migrate to a physical computer with a different processor version” in the Processor > Compatibility menu.
  4. Hyper-V Manager processor compatibility configuration view

Secondly, for the registry for Android SDK Tools path, I created a new “Android SDK Tools” key under

HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\
because there wasn’t existing key like others. Then I added a string value with “Path” for name and the Android SDK full path on my computer for data. I could get the Android SDK full path from
Visual Studio > Tools > Options > Xamarin > Android Settings > Android SDK Location

Visual Studio tools options view Copy and paste it to the registry.

Eventually, I could see something different on the output window after executing debugging.

Debugging running view2 Deployment Success!!

Happy Coding!