Advertisement
Android SDK

Common Android Virtual Device Configurations

by

Android developers must target a variety of different Android devices in order to reach the greatest number of users. By properly configuring the Android Emulator to mimic the behavior of different devices, developers can save valuable time and money on testing and identify incompatibilities. In this tutorial, you will learn how to create Android Virtual Device (AVD) configurations for a variety of popular Android devices on the market today. Specifically, you will create AVD configurations for the:

  • HTC Evo 4G
  • Google/HTC Nexus One
  • Motorola Droid
  • T-Mobile/HTC G1
  • Archos 5 Internet Tablet

Final Result Preview

Android Virtual Device Configurations

Assumptions

The authors are assuming the reader has some basic knowledge of Android and have all of the tools installed and working—specifically Eclipse, the Android SDK and the Android ADT plug-in for Eclipse. You will need to use the Android SDK and AVD Manager available within the Eclipse IDE for this tutorial.

Note: If you do not use the Eclipse IDE for Android development, you can still follow this tutorial and create the appropriate AVD configurations using the android.bat (or the android command on Mac & Linux) command–line tool provided in the /tools directory of the Android SDK installation. However, the steps will be different, as you are working on the command-line instead of through the Android SDK and AVD Manager. For more information about the android command-line tool and how to use it to create and manage AVDs, see the Android SDK documentation.

Step 1: Getting Comfortable with the Android SDK and AVD Manager

The Android SDK and AVD Manager is integrated into the Eclipse IDE when you install the Android Development Tools (ADT) plug-in. The Android SDK and AVD Manager is used to keep track of the different Android SDK targets installed on your development machine, as well as to manage the Android Virtual Devices (AVDs) used by the Android Emulator to mimic the behavior of real Android devices.

An Android Emulator must have an AVD configuration in order to function. An AVD represents a unique, persistent system image. Any Settings changed and applications installed while using the AVD within the Emulator will be stored within the system image.

An AVD configuration also describes how the emulator should emulate a real device, including:

  • What version of the Android platform to emulate (API Level) (Note: The target platform is subject to change if, and when, devices receive over-the-air updates)
  • Screen size, density, and resolution
  • SD Card size and contents
  • Hardware details (Camera? Keyboard? Trackball? D-Pad?)

A complete list of hardware emulation options, including settings and their default values, is available in the Android SDK documentation.

You can launch the Android SDK and AVD Manager from the Eclipse toolbar by pressing the button with the green Android icon with the arrow () or by choosing Window->Android SDK and AVD Manager.

Step 2: Creating an AVD to Emulate the HTC Evo 4G

One of the newest Android devices on the market, the HTC Evo 4G is a powerful new phone with a nice big screen, a powerful processor, and a great camera.

The important specs of this device from an Emulator perspective are:

  • Target platform: Currently Android 2.1
  • Screen info: Large screen, high density
  • Lack of keyboard and DPad
  • Lack of trackball

Therefore, let’s create an AVD configuration called Evo4G:

  1. Within Eclipse, launch the Android SDK and AVD Manager
  2. Select “Virtual Devices” from the left-hand options
  3. Click the “New” button to create a new AVD configuration
  4. Name the AVD: “Evo4G”
  5. Select the Target: “Google APIs API Level 7”
  6. Input the SD Card Size: “8GB”
  7. Input the Skin Details: “800x480”
  8. Edit the Hardware Property for Abstracted LCD Density: “217”
  9. Add another Hardware Property for DPad Support: “No”
  10. Add another Hardware Property for Keyboard Support: “No”
  11. Add another Hardware Property for Track-ball Support: “No”
  12. Save the AVD

You have now created an AVD that can be used by the Android Emulator to closely resemble and behave like the HTC Evo 4G. If you launch an Android application in emulator while this AVD, you can see that the screen closely resembles the experience one would have on the actual device. If you own one of these devices, you may immediately notice that the screen doesn’t look the same (software-wise). The emulator does not provide third-party add-ons, such as the HTC Sense UI.

Step 3: Creating an AVD to Emulate the Google Nexus One

Google’s Nexus One is a powerful phone with the latest Android release. Being a device originally sold directly by Google, this phone seems to get updates the soonest. It also has a nice screen and is quite fast, especially with Android 2.2.

The important specs of this device from an Emulator perspective are:

  • Target platform: Currently Android 2.2
  • Screen info: Medium sized, high density
  • No keyboard or DPad
  • Has track-ball

Therefore, let’s create an AVD configuration called NexusOne:

  1. Within Eclipse, launch the Android SDK and AVD Manager
  2. Select “Virtual Devices” from the left-hand options
  3. Click the “New” button to create a new AVD configuration
  4. Name the AVD: “NexusOne”
  5. Select the Target: “Google APIs API Level 8”
  6. Input the SD Card Size: “4GB”
  7. Input the Skin Details: “WVGA800” (800x480)
  8. Add a Hardware Property for Abstracted LCD Density: “252”
  9. Add another Hardware Property for DPad Support: “No”
  10. Save the AVD
Virtual Device Configuration

You have now created an AVD that can be used by the Android Emulator to closely resemble and behave like the Google Nexus One. If you launch an Android application in emulator while this AVD, you can see that the screen closely resembles the experience one would have on the actual device. Here we see a photo that shows the Android Emulator using the NexusOne AVD on the right and an actual Nexus One on the left.

Android Virtual Device

Step 4: Creating an AVD to Emulate the Motorola Droid

The Motorola Droid is one of the most prevalent Android phones available in the United States today. It’s also different from many of the other newer Android handsets in that it has a hardware keyboard.

The important specs of this device from an Emulator perspective are:

  • Target platform: Currently Android 2.1.
  • Screen info
  • Lack of trackball support
  • Has keyboard and DPAD

Therefore, let’s create an AVD configuration called MotoDroid:

  1. Within Eclipse, launch the Android SDK and AVD Manager
  2. Select “Virtual Devices” from the left-hand options
  3. Click the “New” button to create a new AVD configuration
  4. Name the AVD: “MotoDroid”
  5. Select the Target: “Google APIs API Level 7”
  6. Input the SD Card Size: “16GB”
  7. Input the Skin Details: “WVGA854”
  8. Edit the Hardware Property for Abstracted LCD Density: “265”
  9. Add another Hardware Property for Track-ball Support: “No”
  10. Save the AVD
Android Virtual Device

You have now created an AVD that can be used by the Android Emulator to closely resemble and behave like the Motorola Droid. If you launch an Android application in emulator while this AVD, you can see that the screen closely resembles the experience one would have on the actual device.

Step 5: Creating an AVD to Emulate the T-Mobile G1

The T-Mobile G1 was the first publicly available Android handset. Although many users have upgraded to the newer Android devices, many G1s are still around. In fact, as of this writing, a good
50% of activated devices are still running Android 1.5 and Android 1.6—a good indication that G1s and other early Android handsets are still being used.

The important specs of this device from an Emulator perspective are:

  • Target platform: Google add-ons with Android 1.6
  • Screen info: medium density and small
  • Has keyboard and Track-ball, but no DPad

Therefore, let’s create an AVD configuration called TMobileG1:

  1. Within Eclipse, launch the Android SDK and AVD Manager
  2. Select “Virtual Devices” from the left-hand options
  3. Click the “New” button to create a new AVD configuration
  4. Name the AVD: “TMobileG1”
  5. Select the Target: “Google APIs API Level 5”
  6. Input the SD Card Size: “2GB”
  7. Input the Skin Details: “HVGA” (480x320)
  8. Edit the Hardware Property for Abstracted LCD Density: “180”
  9. Add a Hardware Property for DPad Support: “No”
  10. Save the AVD
Android Virtual Device

You have now created an AVD that can be used by the Android Emulator to closely resemble and behave like the T-Mobile G1. If you launch an Android application in emulator while this AVD, you can see that the screen closely resembles the experience one would have on the actual device.

Step 6: Creating an AVD to Emulate the Archos 5 Internet Tablet

Finally, let’s look at an Android device that isn’t a phone. One good option is the Archos 5 Internet Table. Developing for other types of Android devices has its own set of challenges. Without the Google Add-ons, you can’t rely on any particular apps being present. For instance, the Google Maps app won’t be available. The device may still have a Maps app, but you won’t necessarily know how it will behave. Testing without these apps present, as you can do with the emulator, is highly recommended so you know if the application is making assumptions that it shouldn’t.

The important specs of this device from an Emulator perspective are:

  • Target platform: Android 1.6, but no Google Add-ons
  • Screen info: High Density and Large
  • No keyboard
  • No Google APIs
  • No Camera

Therefore, let’s create an AVD configuration called Archos5:

  1. Within Eclipse, launch the Android SDK and AVD Manager
  2. Select “Virtual Devices” from the left-hand options
  3. Click the “New” button to create a new AVD configuration
  4. Name the AVD: “Archos5”
  5. Select the Target: “Android 1.6 API Level 5”
  6. Input the SD Card Size: “2GB”
  7. Input the Skin Details: “WVGA800”
  8. Edit the Hardware Property for Abstracted LCD Density: “194”
  9. Add a Hardware Property for DPad Support: “No”
  10. Add another Hardware Property for Track-ball Support: “No”
  11. Add another Hardware Property for Keyboard Support: “No”
  12. Add another Hardware Property for Camera Support: “No”
  13. Add another Hardware Property for GSM modem Support: “No”
  14. Save the AVD
Android Virtual Device

You have now created an AVD that can be used by the Android Emulator to closely resemble and behave like the Archos 5 Internet Tablet. If you launch an Android application in emulator while this AVD, you can see that the screen closely resembles the experience one would have on the actual device. This next photo shows the Android Emulator using the Archos5 AVD on the right and an actual Archos 5 Internet Tablet on the left.

Android Virtual Device

Step 7: Using a Specific AVD with the Android Emulator

In order to use the AVDs you have created, you need to launch the Android Emulator, assigning it the appropriate AVD. The easiest way to do this from within Eclipse is to choose an Android project and update its Debug or Run Configuration to Target either Manual mode or a specific AVD by name. When you run or debug the application, the appropriate AVD will be loaded (if you chose one) or you will be prompted to manually choose an appropriate AVD from the Android Device Chooser, as shown below.

Android Virtual Device

If you want to be able to control the on-screen size of the emulator, you’ll need to use the “Start…” button from the Device Chooser or from the Android SDK and AVD Manager. You’ll see the following dialog:

Android Virtual Device

Be sure to choose the correct numbers for your desktop display and the device screen size. On my 24” monitor that has a display resolution of 1920x1200, the dpi is 94. You’ll need to calculate this for your own monitor or laptop screen.

Step 8: Being Practical

Although you can now emulate a device in a far more realistic way, there are certain disadvantages to doing this. First, you’re still only just emulating, as we discussed. Second, and more importantly, some of these settings make using the emulator much more difficult. For instance, if you choose to turn off the keyboard, the emulator will honor that and you’ll be forced to use the on-screen keyboard within Android. Also, if you turn off GSM hardware, you will have no way of making a data connection as the Wi-Fi option does not work, either.

Finally, the SD card size directly takes up that much space on your computer. Make sure you use an SD card size that’s large enough for testing your application, but there is no real compelling need to emulate the SD card size exactly. The SD cards are user-replaceable, too, so you can’t guarantee that a user still has the original card in place. So, you have to decide which emulation is most important for you. In addition, the full emulation may be most useful when used with automated testing tools instead of by humans.

Conclusion

In this tutorial, you learned how to create Android Virtual Devices (AVDs) to emulate many popular Android devices, including: the HTC Evo 4G, the Google Nexus One, the Motorola Droid, the T-Mobile G1 and the Archos 5 Internet Tablet.

The Android Emulator is the developer’s most important tool for developing and publishing Android applications but it’s effective if it’s actually emulating the appropriate target devices. That’s where crafting detailed AVD configurations for target handsets becomes essential. Still, it’s important to remember that the Emulator is just pretending—not actually running the hardware and software abilities and constraints unique to that device. To ensure that your application works as expected on a given device, you should always test it on the actual hardware whenever possible. The same AVD can be used to test multiple applications, or multiple AVDs could be created to test different device configurations for a single application.

If you have any questions about this tutorial, feel free to contact us. For more information about Android Virtual Devices (AVDs), check out the Dev Guide documentation at the Android Developer website.

We hope you enjoyed this tutorial and look forward to your feedback!

About the Authors

Mobile developers Lauren Darcey and Shane Conder have coauthored several books on Android development: an in-depth programming book entitled Android Wireless Application Development and Sams TeachYourself Android Application Development in 24 Hours. When not writing, they spend their time developing mobile software at their company and providing consulting services. They can be reached at via email to androidwirelessdev+mt@gmail.com, via their blog at androidbook.blogspot.com, and on Twitter @androidwireless.

Need More Help Writing Android Apps? Check out our Latest Books and Resources!

Buy Android Wireless Application Development, 2nd Edition  Buy Sam's Teach Yourself Android Application Development in 24 Hours  Mamlambo code at Code Canyon

Related Posts
  • Code
    Android SDK
    Integrating Google Play Services on Android85ude preview image@2x
    By integrating your Android apps with Google Play Services, you can access Google services, such as Maps, Drive, and Google+. In this tutorial, we will go through the process of integrating Google Play Services with Android apps.Read More…
  • Code
    News
    Android 2013: A Year in Review and 2014 PredictionsPk45fe preview image@2x
    It was another strong and, may I say, dominant year for the Android platform. It continued to dominate in market share and climb in numbers. Countless devices were released featuring the popular, mobile operating system and not all of those devices were smartphones or tablets. Android is making headway in new territories. 2013 was a busy year for the green robot. Now that the year has come to a close, it's time to recap the action.Read More…
  • Code
    News
    Android 4.4 KitKat: What's NewAe2b1 preview image@2x
    Google released its latest version of Android on October 31, 2013. The new release, version 4.4, is nicknamed KitKat. The release came as a surprise to many as Key Lime Pie and 5.0 had been linked to this update for quite some time. KitKat, however, doesn't disappoint as it's packed with features and updates. In this article, I'll give you an overview overview of what's new in KitKat.Read More…
  • Code
    Android SDK
    Android SDK: SamplesAndroid preview@2x
    In this series, we have been exploring the basics of Android development. We have looked at what you need to know when building the elements in Android apps. In this tutorial, however, you will see that the Android platform provides resources you can learn from. The samples of the Android SDK include complete applications in which you can see functioning examples of typical Android application components. You can use the samples in more than one way, including directly from within Eclipse.Read More…
  • Code
    Android SDK
    Android SDK: Running & DebuggingAndroid preview@2x
    We have been learning how to develop Android apps in this series. In the last tutorial, we looked at connecting hardware and virtual devices to Eclipse. In this tutorial, we will explore running and debugging apps on physical devices and AVDs from Eclipse.Read More…
  • Code
    Android SDK
    Android SDK: Virtual & Physical DevicesAndroid preview@2x
    We are learning about Android app development in this series. We already looked at the basic elements in an Android project and touched on user interface design and data storage along the way. In this tutorial, we are going to explore how to run and interact with your apps on physical and virtual devices. In the next part of the series, we will work through the process of running an app on a physical device and on the emulator. In this part, we'll look at getting our physical and virtual devices set up in Eclipse.Read More…