الشركة الأفضل لبرمجة المواقع والتطبيقات و عرض أفضل سرفيرس في العالم العربي



Managing Virtual Devices | Android Developers


 

Managing Virtual Devices

 

An Android Virtual Device (AVD) is an emulator configuration that lets you model an actual device by defining hardware and software options to be emulated by the Android Emulator.

 

The easiest way to create an AVD is to use the graphical AVD Manager, which you launch from Eclipse by clicking Window > AVD Manager. You can also start the AVD Manager from the command line by calling the android tool with the avd options, from the /tools/ directory.

 

You can also create AVDs on the command line by passing the android tool options. For more information on how to create AVDs in this manner, see Managing Virtual Devices from the Command Line.

 

An AVD consists of:

 

  • A hardware profile: Defines the hardware features of the virtual device. For example, you can define whether the device has a camera, whether it uses a physical QWERTY keyboard or a dialing pad, how much memory it has, and so on.
  • A mapping to a system image: You can define what version of the Android platform will run on the virtual device. You can choose a version of the standard Android platform or the system image packaged with an SDK add-on.
  • Other options: You can specify the emulator skin you want to use with the AVD, which lets you control the screen dimensions, appearance, and so on. You can also specify the emulated SD card to use with the AVD.
  • A dedicated storage area on your development machine: the device's user data (installed applications, settings, and so on) and emulated SD card are stored in this area.
  •  

Example of an AVD with API level 15

avd_Android_virtual_device

 

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

 

 

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

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

 

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
 
Configuring an AVD to use graphics acceleration

You need Android SDK Tools rev 17 or higher, then start by creating a new AVD with the target value of Android 4.0.3 (API Level 15), using SDK rev 3 and System Image rev 2 (or higher).

If you want to have graphics acceleration enabled by default for this AVD, in the Hardware section of the AVD configuration, click New, select GPU emulation and set the value to Yes.

You need to make sure to hit enter when you change the value in the list before closing the dialog.


You can also turn on graphics acceleration at run time:
emulator -avd -gpu on
 

How can I move .android folder to a different location?

 

  • Move .android folder to E:\Android\
  • Create environment variable called ANDROID_SDK_HOME and set its value to E:\Android

Setting environment variable in Windows XP:

  1. Right-click on My Computer and choose "Properties")
  2. Click the "Advanced" tab
  3. Click the button "Environment Variables".
  4. Add New variable
 

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.