Microsoft Surface Duo Android Emulator update

Andrei Paval

Hello Android developers,

We’re excited to announce the release of an updated Surface Duo Emulator that is based on Android 11 and runs as an Android Virtual Device (AVD), supporting different screen sizes for both Surface Duo and Surface Duo 2 devices.

Download now

You can download the Surface Duo Emulator package from the Microsoft Download Center. We now support both Android 10 and Android 11 on Windows, Mac, and Linux platforms. You can choose the right one from the following list based on your development environment:

List of all the emulator installer download options including Windows, Mac, and Ubuntu files for Android 10 and Android 11
Figure 1. Download file list in Microsoft Download Center

As a prerequisite for the Surface Duo Emulator, if you install the Android SDK (Build-Tools, Platform-Tools, and Android Emulator) from Android Studio in a non-default location, please make sure you also set the ANDROID_SDK_ROOT environment variable pointing to this location according to Android’s documentation.

We recommend using the latest stable version of Google Android Emulator, but in any case, use at least a version higher than 30.9.5.

Windows installation

For Windows users, the installation process stays the same. Just launch the installer and follow the Setup Wizard. The default install location is %USERPROFILE%\SurfaceDuoEmulator but it is recommended you use a new unique custom path each time. After the installation, the two following new app icons will be shown on your desktop and in the Start Menu, which you can use to launch the emulator for either Surface Duo or Surface Duo 2 devices.

Please make sure you install the new emulator in a different folder by choosing the location of the installation in the setup wizard or uninstall the previous Surface Duo emulator before you install this new version. Overwriting the previous version (prior to March 2022) with the new package or installing different Android versions on top of each other (like Android 10 and Android 11) may cause some corruption of the emulator user data.

Surface Duo emulator icon Surface Duo 2 emulator icon
Figure 2. App icons on the desktop on Windows

macOS installation

For Mac users, the installation will be slightly different. After downloading and opening the .dmg file, you will see a SurfaceDuoEmulator_<version> folder. Please make sure you copy the whole folder to a different location on your local storage drive since there are some hidden files you may miss if you open the folder and copy the contents inside. Inside the folder we now provide dedicated scripts for each device to help you use the emulator easily for different development scenarios.

The device specific scripts have the following functionality:

  • run_SurfaceDuo.sh/.bat – launch the Surface Duo emulator
  • run_SurfaceDuo2.sh/.bat – launch the Surface Duo 2 emulator
  • run_clean_<deviceName>.sh/.bat – launch the emulator without loading the previous snapshot
  • run_wipe_<deviceName>.sh/.bat – delete all the userdata and then launch the emulator
  • run_vs_<deviceName>.sh/.bat – launch the emulator with the Visual Studio Android SDK
  • run_vs_clean_<deviceName>.sh/.bat – launch the emulator with the Visual Studio Android SDK without loading the previous snapshot
  • run_vs_wipe_<deviceName>.sh/.bat – delete all the user data and then launch the emulator with the Visual Studio Android SDK

List of shell scripts that can be run on macOS
Figure 3. Emulator package content for Mac

Linux installation

For Linux users, the installation process stays the same. Just navigate to the directory where you downloaded the package and run the following command, replacing the correct file name:

sudo dpkg -i SurfaceDuoEmulator_<version>_ubuntu.deb

Then follow the installer instructions and the emulator will be installed in /opt/surface-duo-emulator. You will find two new app icons in Linux’s application list, like in the picture below:

Emulator icons on Ubuntu
Figure 4. App icons in Ubuntu’s application list

The installer will remove by default the old installation in /opt/surface-duo-emulator and install in the same location. Don’t forget to backup any important data from the emulator folder you would like to keep.

Android Virtual Device

An Android Virtual Device or AVD is a configuration that can be loaded by the emulator to emulate the characteristics of a real Android device, in our case both Surface Duo and Surface Duo 2.

The working directory of the emulator contains:

  • run*.bat/.sh scripts – used to launch the emulator with different configurations and arguments.
  • system-images folder – It contains the Android 11 (API 30) system images with the Surface Duo APIs. These are read-only and used by all the AVDs.
  • .android/avd folder – It contains the hardware profiles and the storage area for the writeable device images of the AVDs. Because it starts with “.” (dot) it may be hidden in your file explorer on Linux and Mac, depending on your configuration.

AVD folders and ini files for the two hardware profiles
Figure 5. Surface Duo AVDs hardware profiles

The run.bat and run.sh scripts should not be executed directly without command line arguments; they are indirectly called from the other device specific scripts. The launch scripts will figure out based on the command line arguments and the environment variables which Android SDK to use and which AVD configuration to load.

If you want to run the emulator from command line with other arguments you can use the main run.bat/.sh script like this, depending on your host operating system:

run.bat/.sh <as|vs> <device_name> <api_level> [<opt_arg1> <opt_arg2>]

where the arguments can be:

  • as (Android Studio SDK) or vs (Visual Studio SDK, only for Windows and Mac)
  • device_nameSurfaceDuo2 or SurfaceDuo
  • api_level – the API level of the system images used, e.g. Android 11 is API level 30
  • opt_arg1/2-no-snapshot-load, -wipe-data or any other described in the Google emulator documentation, but at most two at the same time.

Customizing things

The emulator launch scripts use the selected Android SDK for identifying and launching the actual Android Emulator executable according to the host operating system and CPU architecture. If you installed the Android SDK to a non-default path, use some custom SDK or built you own emulator executable, you can configure it by editing run.bat/.sh using a text editor, but first make a backup copy to something like run_tmp.bat/.sh. Then update one of the path variables at the top of the file which are different for Windows and Linux/Mac:

rem ##### ENSURE THE ANDROID SDK LOCATION BELOW IS CORRECT #######
set "DEFAULT_ANDROID_SDK_LOCATION_WIN=%LOCALAPPDATA%\Android\Sdk"
set "DEFAULT_ANDROID_SDK_LOCATION_WIN_VS=C:\Program Files (x86)\Android\android-sdk"
##### ENSURE THE ANDROID SDK LOCATION BELOW IS CORRECT #######
DEFAULT_ANDROID_SDK_LOCATION_LINUX=~/Android/Sdk
DEFAULT_ANDROID_SDK_LOCATION_LINUX_2=/usr/lib/android-sdk
DEFAULT_ANDROID_SDK_LOCATION_MAC=~/Library/Android/sdk
DEFAULT_ANDROID_SDK_LOCATION_MAC_VS=~/Library/Developer/Xamarin/android-sdk-macosx

Although it’s not needed in most cases, you can also customize the hardware properties of the AVD. Each AVD has its own config file, called config.ini, which can be found in the .android/avd/<avd_name>.avd/ folder, which can be modified using a text editor. This file contains on each line a construct like this: <property-name>=<property-value> which can be changed. As a precaution, make a backup copy of this file before editing.

Most properties do not need to be changed because they reflect the characteristic of the actual physical device, but among the ones which could be updated for test purposes are:

  • disk.dataPartition.size=4G – size of internal storage (in GB)
  • hw.camera.back=virtualscene – emulated type of rear facing camera
  • hw.camera.front=emulated – emulated type of front facing camera
  • hw.ramSize=3072 – size of RAM memory (in MB)

Integration with IDEs

The main IDEs used for Android development which can use an Android Emulator are Android Studio and Visual Studio. The Surface Duo Emulator is supported by both.

The Surface Duo AVDs will not appear in the Android Device Manager of either tool because it is not installed in their working directory, but it is compatible. To use the Surface Duo AVDs, it will need to be manually launched from the desktop or Start Menu shortcuts or from the launch scripts.

After the Surface Duo Emulator has started, it can be selected as the device on which to load and run the built app to perform debugging or execute tests.

The emulator can be identified by its AVD name (e.g. Surface_Duo_2_API_30), the same that appears in the title bar and in the IDE device selection drop-down list. The AVD name also contains the API level of the system images that it is running.

Android Studio device selector
Figure 6. Surface Duo 2 AVD in Android Studio

Visual Studio device selector
Figure 7. Surface Duo 2 AVD in Visual Studio

Different screen sizes

One of the main differences between Surface Duo and Surface Duo 2 devices are screen sizes. Now you can launch the emulator which reflects the actual screen dimension when developing your application for either Surface Duo device.

Diagram of Surface Duo 2 screen dimensions
Figure 8. Surface Duo 2 screen dimension

Diagram of Surface Duo screen dimensions
Figure 9. Surface Duo screen dimension

Home screen updates

We also refreshed the home page of the emulator with some preloaded app samples.

Surface Duo emulator screenshot showing home screen icons and news widget
Figure 10. New home screen with preloaded apps

You can learn more about these two new sample applications to the emulatorin this blog, Dual Screen Experience application, which provides developers and designers with the ability to explore the dual-screen form factor for productivity on the go.

Surface Duo emulator showing sample app with a map and guitar product list
Figure 11. Dual Screen Experience Example

The Compose NavigationRail sample demonstrates how to use NavigationRail in foldable and large screen devices.

Surface Duo emulator showing Jetpack Compose sample with images of animals
Figure 12. Compose NavigationRail Sample

Feedback and resources

Check out the Surface Duo developer documentation and past blog posts for links and details on all our samples. You can find our samples on GitHub.

If you have any questions about the Surface Duo Emulator, or would like to tell us about your apps, use the feedback forum or message us on Twitter @surfaceduodev.

0 comments

Discussion is closed.

Feedback usabilla icon