Use the Surface Duo emulator with Visual Studio
This article describes functionality and guidance that is in public preview and may be substantially modified before it's generally available. Microsoft makes no warranties, express or implied, with respect to the information provided here.
To build Android apps with Xamarin in C# using Visual Studio, set up these tools then follow the instructions on this page:
- Get the latest version of Visual Studio and ensure Xamarin is installed.
- Ensure the Android SDK is installed via these Visual Studio instructions.
Install the emulator preview
Get the installer from the Microsoft Download Center:
Choose the .zip package for Windows or the .dmg for macOS.
When the download has completed, run the installer.
The installer places icons in the Start menu, inside a SurfaceDuoEmulator folder. Use the icon labelled Surface Duo Emulator for Visual Studio to open the emulator before attempting to deploy inside Visual Studio.
Run the emulator
Visual Studio will not automatically start the Surface Duo emulator, so you should manually open it before attempting to deploy or debug your Xamarin app.
Follow these instructions to start the emulator, after which it will appear as a deployment option in Visual Studio:
After completing the SDK Setup, you can launch the Surface Duo Emulator for Visual Studio via the Start menu link.
In the installation folder, there is a batch file run_vs.bat which you can execute directly. There is also a run_vs_clean.bat file which will start the emulator in a fresh state (rather than continue a previous session).
If the emulator does not start, you might need to update the pointer to your Android SDK installation.
The installation folder contains start-up scripts named run and run_vs. The run scripts are intended for developers using Android Studio and the run_vs scripts are for Visual Studio users. The differences are the Android SDK location and the port used for the emulator.
If the emulator is running but does not appear as a deployment option in Visual Studio, close the emulator and re-start, confirming that you are using the script with vs in the name.
Debugging your Xamarin Android App
Open your Project in Visual Studio, build it, and select
<build> (Android 10.0 - API 29) (in the list of Running Devices) and deploy.
Debugging (breakpoints, step into, step over, etc) will all work as usual.
Update the pointer to your Android SDK
If you changed the installation location of the Android SDK from the default, you will need to update the
run_vs script to point to the correct installation location. Otherwise, the emulator will not run when you click the shortcut or run the script.
- Find the installation location of the Surface Duo Emulator. The default location is
- Open the
artifactsfolder inside of the installation folder.
- Make a backup copy of
run_vs.bat- You can copy it to something like
- Open the file
run_vs.batin a text editor.
- Verify the
ANDROID_SDK_LOCATIONpath value near the top of the file is correct.
rem ##### ENSURE THE SDK LOCATION BELOW IS CORRECT: ####### set ANDROID_SDK_LOCATION=C:\Program Files (x86)\Android\android-sdk