Managing Virtual Devices with the Android Device Manager

This article explains how to use the Android Device Manager to create and configure Android Virtual Devices (AVDs) that emulate physical Android devices. You can use these virtual devices to run and test your app without having to rely on a physical device.

Overview

After you have verified that hardware acceleration is enabled (as described in Hardware Acceleration for Emulator Performance), the next step is to use the Android Device Manager (also referred to as the Xamarin Android Device Manager) to create virtual devices that you can use to test and debug your app.

This article explains how to use the Android Device Manager to create, duplicate, customize, and launch Android virtual devices.

Screenshot of the Android Device Manager in the Devices tab

You use the Android Device Manager to create and configure Android Virtual Devices (AVDs) that run in the Android Emulator. Each AVD is an emulator configuration that simulates a physical Android device. This makes it possible to run and test your app in a variety of configurations that simulate different physical Android devices.

Requirements

To use the Android Device Manager, you will need the following:

  • Visual Studio 2017 version 15.7 or later is required. Visual Studio Community, Professional, and Enterprise editions are supported.

  • Visual Studio Tools for Xamarin version 4.9 or later.

  • The Android SDK must be installed (see Setting up the Android SDK for Xamarin.Android), and SDK tools version 26.1.1 or later must be installed as explained in the next section. Be sure to install the Android SDK at the following location (if it is not already installed): C:\Program Files (x86)\Android\android-sdk.

Launching the Device Manager

Launch the Android Device Manager from the Tools menu by clicking Tools > Android > Android Device Manager:

Launching from the Tools menu

If you see the following error dialog on launch, see Android Emulator Troubleshooting for workaround instructions:

Android SDK instance error

Before you can use the Android Device Manager, you must install Android SDK tools version 26.1.1 or later. If Android SDK tools 26.1.1 or later is not installed, you may see this error dialog on launch:

Android SDK instance error dialog

If you see this error dialog, click Open SDK Manager to open the Android SDK Manager. In the Android SDK Manager, click the Tools tab and install the following:

  • Android SDK Tools 26.1.1 or later
  • Android SDK Platform-Tools 27.0.1 or later
  • Android SDK Build-Tools 27.0.3 or later

These packages should be shown with Installed status as seen in the following screenshot:

Installing Android SDK Tools 27.0

After these packages are installed, you can close the SDK Manager and re-launch the Android Device Manager.

Main Screen

When you first launch the Android Device Manager, it presents a screen that displays all currently-configured virtual devices. For each device, the Name, Operating System (Android API Level), CPU, Memory size, and screen resolution are displayed:

List of installed devices and their parameters

When you click a device in the list, the Start button appears on the right. You can click the Start button to launch the emulator with this virtual device:

Start button for a device image

After the emulator starts with the selected virtual device, the Start button changes to a Stop button that you can use to halt the emulator:

Stop button for the running device

New Device

To create a new device, click the New button (located in the upper right-hand area of the screen):

New button for creating a new device

Clicking New launches the New Device screen:

New Device screen of the Device Manager

To configure a new device in the New Device screen, use the following steps:

  1. Select a physical device to emulate by clicking the Device pull-down menu:

    Device pull-down menu

  2. Select a system image to use with this virtual device by clicking the System image pull-down menu. This menu lists the installed system device manager images under Installed. The Download section lists system device manager images that are currently unavailable on your development computer but can be automatically installed:

    System image pull-down menu

  3. Give the device a new name. In the following example, the new device is named Nexus 5 API 25:

    Naming the new device

  4. Edit any properties that you need to modify. To make changes to properties, see Editing Android Virtual Device Properties.

  5. Add any additional properties that you need to explicitly set. The New Device screen lists only the most commonly-modified properties, but you can click the Add Property pull-down menu (in the bottom left-hand corner) to add additional properties. In the following example, the hw.lcd.backlight property is being added:

    Add Property pull-down menu

  6. Click the Create button (lower right-hand corner) to create the new device:

    Create button

  7. You might get a License Acceptance screen. Click Accept if you agree to the license terms:

    License Acceptance screen

  8. The Android Device Manager adds the new device to the list of installed virtual devices while displaying a Creating progress indicator during device creation:

    Creation progress Indicator

  9. When the creation process is complete, the new device is shown in the list of installed virtual devices with a Start button, ready to launch:

    Newly-created device ready to launch

Edit Device

To edit an existing virtual device, select the device and click the Edit button (located in the upper right-hand corner of the screen):

Edit button for modifying a new device

Clicking Edit launches the Device Editor for the selected virtual device:

Device Editor screen

The Device Editor screen lists the properties of the virtual device in the first column, with the corresponding values of each property in the second column. When you select a property, a detailed description of that property is displayed on the right.

For example, in the following screenshot the hw.lcd.density property is being changed from 420 to 240:

Device Editing example

After you have made the necessary configuration changes, click the Save button. For more information about changing virtual device properties, see Editing Android Virtual Device Properties.

Additional Options

Additional options for working with devices are available from the … menu in the upper right-hand corner:

Location of additional options menu

The additional options menu contains the following items:

  • Duplicate and Edit – Duplicates the currently-selected device and opens it in the New Device screen with a different unique name. For example, selecting VisualStudio_android-23_x86_phone and clicking Duplicate and Edit appends a counter to the name:

    Duplicate and Edit screen

  • Reveal in Explorer – Opens a Windows Explorer window in the folder that holds the files for the virtual device. For example, selecting Nexus 5X API 25 and clicking Reveal in Explorer opens a window like the following:

    Results of clicking Reveal in Explorer

  • Factory Reset – Resets the selected device to its default settings, erasing any user changes made to the internal state of the device while it was running (this also erases the current Quick Boot snapshot, if any). This change does not alter modifications that you make to the virtual device during creation and editing. A dialog box will appear with the reminder that this reset cannot be undone. Click Wipe user data to confirm the reset.

  • Delete – Permanently deletes the selected virtual device. A dialog box will appear with the reminder that deleting a device cannot be undone. Click Delete if you are certain that you want to delete the device.

Troubleshooting

The following sections explain how to diagnose and work around problems that may occur when using the Android Device Manager to configure virtual devices.

Android SDK in Non-Standard Location

Typically, the Android SDK is installed at the following location:

C:\Program Files (x86)\Android\android-sdk

If the SDK is not installed at this location, you may get this error when you launch the Android Device Manager:

Android SDK instance error

To work around this problem, do the following:

  1. From the Windows desktop, navigate to C:\Users\username\AppData\Roaming\XamarinDeviceManager:

    Android Device Manager log file location

  2. Double-click to open one of the log files and locate the Config file path. For example:

    Config file path in log file

  3. Navigate to this location and double-click user.config to open it.

  4. In user.config, locate the <UserSettings> element and add an AndroidSdkPath attribute to it. Set this attribute to the path where the Android SDK is installed on your computer and save the file. For example, <UserSettings> would look like the following if the Android SDK was installed at C:\Programs\Android\SDK:

    <UserSettings SdkLibLastWriteTimeUtcTicks="636409365200000000" AndroidSdkPath="C:\Programs\Android\SDK" />
    

After making this change to user.config, you should be able to launch the Android Device Manager.

Snapshot disables WiFi on Android Oreo

If you have an AVD configured for Android Oreo with simulated Wi-Fi access, restarting the AVD after a snapshot may cause Wi-Fi access to become disabled.

To work around this problem,

  1. Select the AVD in the Android Device Manager.

  2. From the additional options menu, click Reveal in Explorer.

  3. Navigate to snapshots > default_boot.

  4. Delete the snapshot.pb file:

    Location of the snapshot.pb file

  5. Restart the AVD.

After these changes are made, the AVD will restart in a state that allows Wi-Fi to work again.

Generating a Bug Report

If you find a problem with the Android Device Manager that cannot be resolved using the above troubleshooting tips, please file a bug report by right-clicking the title bar and selecting Generate Bug Report:

Location of menu item for filing a bug report

Summary

This guide introduced the Android Device Manager available in Visual Studio for Mac and Visual Studio Tools for Xamarin. It explained essential features such as starting and stopping the Android emulator, selecting an Android virtual device (AVD) to run, creating new virtual devices, and how to edit a virtual device. It explained how to edit profile hardware properties for further customization, and it provided troubleshooting tips for common problems.