Tek Eye Logo

Tek Eye

Set Up an Android Virtual Device for App Testing

What is an Android Virtual Device (AVD)? An AVD is an emulation of a real Android machine on a PC. It enables testing of Android applications (Apps) on a code development computer.

Android Logo

Why Use Android Virtual Devices?

Android has been around for a few years with devices manufactured to cover various market segments, from mobile and tablet through to watches and TV. There are low cost devices and high specification, high value devices and a wide range of hardware options. For all these reasons there is a large range of Android devices running various operating system (OS) versions. A successful App will run on many of these devices. However, an App developer may not physically own a good range of devices. Testing is done on a small selection of real devices supported by AVDs.

The Google Nexus 7 by Asus

Use AVDs to Test Apps on Different Hardware Profiles

The Android Software Development Kit (SDK) comes with the device emulation tool. Allowing different combinations of AVD hardware and OS versions to be configured. Testing on different AVD combinations reduces issues related to hardware differences in real devices, as used by Android Play customers. Boosting confidence that the App will run reliably when released.

Other reasons for using AVDs for testing:

  • Multiple AVD configurations to test an App at different screen sizes.
  • Different (emulated) hardware configurations can be used, for example a device with a keyboard or without.
  • A compiled App is automatically installed and started when the Run button is pressed in Android Studio.
  • Testing on AVDs reduces the amount of physical device testing.
  • AVDs can be used alongside a physical device.
  • You don't need to handicap you physical device to induce error conditions, e.g. testing on a device with no SD card, just set up an AVD with no SD card.
  • An AVD can simulate network events without the costs involved in using a physical device, e.g. simulate phone calls or send an SMS between two AVDs.
  • Simulate GPS data from an AVD from different physical locations without moving from your desk.
  • When App users report bugs you can try and mimic their hardware configurations using AVDs.

Note: Real Android devices plugged into development machines usually provide better performance for testing Apps than AVDs.

Configuring an AVD

Set up an AVD for App testing using the AVD Manager program. In Android Studio to run AVD Manager use the toolbar icon or select Android in the Tools menu. (There is a version of AVD Manager.exe that can be run outside of Studio, in the Android SDK install directory. To locate it in Windows type AVD at the Start screen to find it.)

AVD Manager Toolbar Icon

To create an AVD select the Create Virtual Device button. The Virtual Device Configuration wizard loads.

AVD Manager Main Dialog

Choose a common predefined device or generate a new device profile for testing specific hardware configurations. Use the remaining wizard screens to configure the AVD.

Hardware Profile Settings

This table lists the AVD supported properties that can be configured for emulated hardware and AVD start up configuration.

Property Values Description
Device Name String Name of the device profile
Device Type Phone/Tablet, Wear or TV Device category
Screen Size Inches Length of screen diagonal
Resolution X and Y Pixels Number of width and height pixels
Memory Set RAM in bytes, KB, MB, GB or TB Amount of physical RAM emulated
Hardware Input Physical Back/Home/Menu buttons and Keyboard Emulate buttons and keyboard
Orientation Portrait and/or Landscape Supported orientation states
Cameras Front and/or Back Supported cameras (emulated or PC cam)
Sensors Accelerometer, Gyroscope, GPS, Proximity Supported sensors
Skin and frame Select appearance Skin the emulated device
System Select Android OS version Android API to emulate
Scale Auto or select dp units to pixels Customise screen density
Performance Auto, GPU for graphics, software emulation GPU Emulation
Multi-Core 1 to 4 Select number of cores
Network Speed Full, HSDPA, UMTS, EDGE, GPRS, HSCSD, GSM Emulate the network speed
Network Latency UMTS, EDGE, GPRS Emulate the network latency
VM Heap Java heap in bytes, KB, MB, GB or TB Java Virtual Machine heap
Internal Storage Non-removal space in bytes, KB, MB, GB or TB Emulated internal memory
SD card Size in bytes, KB, MB, GB or TB or existing file Emulated removable SD card
Keyboard Enable/Disable Allow keyboard input

Notes on AVD Settings

  • CPU/ABI refers to the target CPU type and the Application Binary Interface (ARM/x86/x86_64). x86 targets perform better than ARM, especially with the Intel Hardware Acceleration Manager (HAXM) installed (by default) on the development computer.
  • When naming a new emulated Android device make it descriptive, for example if emulating a device with a version 4.4 operating system and medium resolution screen (HVGA) a name such as And-v4.4-HVGA is better than Android-Device as it is easier to pick out in the list of configured AVDs.
  • For the emulated Secure Digital (SD) card the bigger the specified size the bigger the file created on the host computer. Alternatively select an existing SD card image, allowing SD card data sharing amongst different AVDs. On a Windows machine the sdcard.img files will be found in the sub-folders of the avd directory, under the .android directory in the logged on user's profile. (Use the Show on Disk drop down menu option next to the AVD listed in the AVD Manager.)
  • Use snapshots if you want the runtime state of the emulated device to persist between sessions. It also reduces the start up time of an AVD for subsequent runs. Though shutdown is longer as the snapshot is written to disk, and host GPU cannot be used to improve AVD graphics performance.
  • Use the Wipe Data drop down menu option in the AVD Manager to clear data in the AVD. When the AVD is started the user data file is reset, any user data generated from previous sessions of the selected AVD is lost.

Note on HAXM

The Intel Hardware Accelerated Execution Manager (HAXM) software is installed by default with Android Studio (unless deselected), alternatively see the Intel HAXM home page. HAXM is a hardware assisted virtualization engine (hypervisor). To benefit from HAXM the following is required:

  • Check the bios documentation for your PC to see if the motherboard and processor of your development machine supports Intel VT (Virtualization Technology).
  • Intel VT must be turned on in the BIOS (see your PCs documentation on how to do that).
  • If HAXM has not been installed by Studio download it via the Android SDK using SDK Manager (under Extras) or from Intel. The version of HAXM installed by Studio is out of date. Uninstall it via control panel and install the latest version.

Launching AVDs

Once the AVD has been defined it will be listed in the AVD Manager window. The AVD is ready to be loaded using the launch (i.e. run or play) button. Once loaded it can be used like any other Android device and driven from the mouse (or keyboard) of the development computer.

AVDs Running

See Also

Additional details on AVDs and emulation is available in the Android developer documention. The emulator key mapping is a useful reference.

Author:  Published:  Updated:  

ShareSubmit to TwitterSubmit to FacebookSubmit to LinkedInSubmit to redditPrint Page

Do you have a question or comment about this article?

(Alternatively, use the email address at the bottom of the web page.)

 This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

markdown CMS Small Logo Icon ↓markdown↓ CMS is fast and simple. Build websites quickly and publish easily. For beginner to expert.


Articles on:

Android Programming and Android Practice Projects, HTML, VPS, Computing, IT, Computer History, ↓markdown↓ CMS, C# Programming, Using Windows for Programming


Free Android Projects and Samples:

Android Examples, Android List Examples, Android UI Examples



Tek Eye Published Projects