How to Create an Android Virtual Device
You might be itching to run some code, but first you must have something that can run an Android program: either an Android device (a phone, a tablet, an Android-enabled toaster — whatever) or a virtual device. An Android Virtual Device (AVD) is a test bed for Android code on the development computer.
The Android SDK comes with its own emulator — a program that behaves like a phone or a tablet but runs on the development computer. The emulator translates Android code into code that the development computer can execute. But the emulator doesn’t display a particular phone or tablet device on the screen.
The emulator doesn’t know what kind of device you want to display. Do you want a camera phone with 800-x-480-pixel resolution, or have you opted for a tablet device with its own built-in accelerometer and gyroscope? All these choices belong to a particular AVD. An AVD is simply a bunch of settings, telling the emulator all the details about the device to be emulated.
Before you can run Android apps on your computer, you must first create at least one AVD. In fact, you can create several AVDs and use one of them to run a particular Android app.
To create an AVD, follow these steps:
In the Eclipse main menu, choose Window→Android Virtual Device Manager.
The Android Virtual Device Manager window opens.
In the Android Virtual Device Manager window, click New, as shown in the figure.
The Create New Android Virtual Device (AVD) window opens. That’s nice!
In the AVD Name field, type a new name for the virtual device.
You can name your device My Sweet Petunia, but in the figure, the device is named Nexus7_Android4.2. The name serves as a reminder of this device’s capabilities.
In the Device drop-down menu, select a device type.
In this figure, Nexus 7 (7.27″, 800 x 1280: tvdpi) is selected.
Determine the kind of secure digital (SD) card your device has.
In the figure, an SD card with a modest 1000 MiB, which is roughly 1 gigabyte, is selected. Alternatively, you could select the File radio button and specify the name of a file on your hard drive. That file would be storing information as though it were a real SD card on a real device.
Leave the other choices at their defaults (or don’t, if you don’t want to) and click the Create AVD button.
The computer returns you to the Android Virtual Device Manager window, where you see a brand-new AVD in the list, as shown in the figure.
And that does it! You’re ready to run your first Android app.