Try Tuts+ Premium, Get Cash Back!
Common Android Virtual Device Configurations

Common Android Virtual Device Configurations

Tutorial Details
  • Technology: Eclipse + Android SDK
  • Difficulty: Beginner
  • Estimated Completion Time: 30 minutes

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: “800×480”
  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” (800×480)
  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” (480×320)
  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 1920×1200, 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

Note: Want to add some source code? Type <pre><code> before it and </code></pre> after it. Find out more
  • http://am-creations.fr Mathieu

    Very usefull !! thanks

  • Hannes Holste

    This is a nice reference, thanks!

  • http://360signals.com/ Maor

    Thanks for the great tutorial! Sure is useful!!

  • Jared

    Thought i’d add this…

    Valid SD card sizes when creating a new AVD

    0-8: invalid
    9-2046: valid
    2047-4104: invalid
    4105-6143: valid
    6144-8200: invalid
    8201: valid

    • http://androidbook.blogspot.com/ Shane Conder & Lauren Darcey
      Author

      Thanks for the input.

      And … that’s pretty funny. When trying to create one of, say, 3050MiB, I get the error “SD Card size must be at least 9MB.” I think their comparison code is checking against a 32bit value or something.

      • http://androidbook.blogspot.com/ Shane Conder & Lauren Darcey
        Author

        Also, the “mksdcard” app does not have this problem. You can create one of 3050M with the following command at the command line:

        ./mksdcard 3050M test.sd

      • http://www.gaboesquivel.com Gabo Esquivel

        +1 …same problem here “SD Card size must be at least 9MB”

  • Cricket La Chica

    Great tutorial! Just a question though… the 800px high emulators that you’ve setup—for instance, the one for Droid—doesn’t seem to fit on my 13″ MBP display. If I modify that to say, 600px high, I can compute for the matching width – but how do I compute for the LCD density? Or will it still be the same?

    • http://androidbook.blogspot.com/ Shane Conder & Lauren Darcey
      Author

      No, that will not be the same. You have three choices, though:

      1. Set the launch size to be small enough to fit on your screen: For example, in Step 7, Second image, set the screen size so it fits on your MBP. This _should_ just control the scaling and not the logic for drawing. The only real downsize is that you can’t see, pixel-for-pixel, what things will look like. You can, however, get a general idea.

      2. Use an external monitor with a higher resolution. Even on a regular 1920×1200 display, the 800 pixel high emulators use up a lot of vertical screen real estate when you add in their borders and regular OS title bars and such. At some point, though, mobile resolutions will get high enough that even this option will revert to option 1.

      3. Test on a real device with that screen resolution. Of course, the premise is that you don’t have this, so it may not be viable or possible.

      If you change the pixel resolution in the emulator, you’re change what it’s emulating. Thus, you aren’t testing against the correct pixel screen size.

  • Jaime

    Great post right there, full of info you don’t normally find. Cheers on that.

    One question tough, do you know if there is any way of launching several emulators at the same time when I choose to “run” the app? It would be most convenient for testing if the UI layouts are properly working in all device configurations.

    I’m inclined to think that this is possible, as you can launch a new emulator while the current one is running (tough this will make the debuger and logcat get a bit lost on which device to choose) but I haven’t been able to figure it out.

    Any ideas?

    • http://androidbook.blogspot.com/ Shane Conder & Lauren Darcey
      Author

      Through Eclipse, it’s generally just one at a time. Presumably, one could write a script to launch multiple emulators and load the apk onto all of them.

      I fear my dev machine wouldn’t be able to handle very many at once without getting too slow, but on a test machine and with automated testing, I could see this being useful.

      Good luck!

    • G. H. Chinoy

      Pop open a command prompt and run another emulator directly, emulator -avd [name of emulator avd file, sans .avd] or open the SDK Manager and start another one. DDMS in Eclipse will see both and you can switch between their logcats.

  • Stelios

    Are there any settings for the HTC Desire device??

  • Brian

    I am typing in the specs when i am trying to create a new device but when i click create AVD it say the system cannot find the path specified. I was wondering if anyone new what was wrong.

  • Jon

    Good tutorial. It’s also worth noting that Motorola provides custom AVDs for many of their phones on their MOTODEV site. A free account is required, but I also find their custom-rolled build of Eclipse, called MOTODEV Studio for Android, to be even more useful than stock Eclipse + ADT.

  • tash

    thanks. i followed the tutorials. only thing is im not getting the controls on the side, just an emulation of the screen. not sure what i missed.

  • Stacy

    Any settings for the Motorola i886?

  • Bill Wilson

    Thank you for this tutorial. The most frustrating thing about learning new things is getting good examples. In this case, getting the specs on new Android devices is very time consuming. Your tutorial helped immensely.

  • Brad

    Every time I create virtual device with settings listed for MotoDroid SDK/AVD manager and Eclipse freeze and will not respond. Then, after manually closing Eclipse, I have window with following error message:

    Java was started but returned exit code=-805306369

  • Brad Bailey

    How about this. I am trying to launch an AVD and I keep getting this message:
    invalid command-line parameter: and.
    Hint: use ‘@foo’ to launch a virtual device named ‘foo’.
    please use -help for more information

    has anyone else encountered this issue? How do I fix it?

  • Chalaco

    Great article!! Thanks

  • Ryan

    What kind of system resources does running just one these virtual machines take? I see that the Manager will actually allocate the size of the virtual SD card on your hard drive but what about things like RAM? Will an AVD with 1 gig of RAM actually require that much? Is this going to kill my inspiron….?

  • http://www.radiantsoft.com Matthew Gravatt

    Super helpful! Thanks!

  • 8gigless

    You should have mentioned in the walkthru that specifying an 8gig SD card actually takes up 8gig on my hard drive. Mentioning it 9/10ths of the way down the page is no good.

  • http://www.lulu.com/spotlight/blackbirdcraven B. Clay Shannon

    Nice article, thanks; however, as it’s a bit long in the tooth, perhaps it’s time for an update. I can’t even install the Google APIs for version 7 or 8. I don’t know if they’ve been deprecated and Google isn’t making them available any longer, or it’s simply a matte of cobwebs in the server room, but an update with the latest Eclipse (which separates the SDK Manager and the AVD tool into two separate dialogs) and newer phones and devices would be way way cool.

  • Janice

    Very outdated.

    Get the LATEST SDK and you’ll see none of this “help” applies anymore.

  • Yvonne

    What does it mean when my AVD doesn’t have any standard home/back/menu buttons?

    Do I have to “turn these on” before they appear?

  • Tom

    Yeah, gotta say, this seems to be a bit outdated now. I’ve pulled up what’s now the AVD Manager, created a new device, but can only target one OS – Android 4.0.3. Not really sure how to target different devices or older versions of the OS.

  • Vince

    Hi !

    Thanks for it !
    I’m wondering why screen attached to text description is not corresponding.
    What is the good value ?

    For instance : Evo4G SD mem 8Go or 64M ?

    Regards,

    Vince

  • Aaron S

    Thank you — this is great for testing the UI!

    I’m also in favor of using a much smaller memory size than the actual device has. I do most of my development on a laptop with a relatively small hard drive. I didn’t realize the AVDs were taking so much disk space…

  • Manikandapadmanabhan

    Truly great and to the point with lots of example.., Outstanding Thanks a ton!!!!

  • BeginnerDev

    Hi,

    It is a very good article about supporting multiple screens.
    My app works well with these mobiles emulator except for the last one : Archos 5 Internet Tablet.
    The image is streched and also there is big black part in the bottom. Why is that ?

  • Gregory

    Hi,

    I am trying to setup a new AVD on my Macbook pro. I do not have an SD card, and need help in setting up using the File option instead. What is this file and type? Is it just a plain empty text file?

    Thanks.
    Greg

  • Sam

    i am not able to change Abstract LCD Density .. there is only value like : 120 , 160 , 240 , 213 , 320

  • Saquib

    Is there any way to export AVD configuration so that others can Import in there eclipse :)

  • Pavan Deshpande