Creating Android Virtual Devices (AVDs)

The Android emulator, included in the Android SDK, allows you to test apps on your computer rather than on an actual Android device. This is useful if you’re learning Android and don’t have access to Android devices, but can be very slow, so a real device is preferred if you have one. There are some hardware acceleration features that can improve emulator performance (developer.android.com/tools/devices/emulator.html#acceleration). Before running an app in the emulator, you must create an Android Virtual Device (AVD )which defines the characteristics of the device you want to test on, including the screen size in pixels, the pixel density, the physical size of the screen, size of the SD card for data storage and more. To test your apps for multiple Android devices, you can create AVDs that emulate each unique device. For this book, we use AVDs for Google’s Android reference devices—the Nexus 4 phone, the Nexus 7 small tablet and Nexus 10 large tablet—which run unmodified versions of Android. To do so, perform the following steps:

1. Open Eclipse.

2. Select Window > Android Virtual Device Manager to display the Android Virtual Device Manager window, then select the Device Definitions tab (Fig. 2).

Image

Fig. 2 | Android Virtual Device Manager window.

3. Google provides preconfigured devices that you can use to create AVDs. Select Nexus 4 by Google, then click Create AVD... to display the Create new Android Virtual Device (AVD) window (Fig. 3), then configure the options as shown and click OK to create the AVD. If you check Hardware keyboard present, you’ll be able to use your computer’s keyboard to type data into apps that are running in the AVD, but this may prevent the soft keyboard from displaying on the screen. If your computer does not have a camera, you can select Emulated for the Front Camera and Back Camera options. Each AVD you create has many other options specified in its config.ini. You can modify this file as described at

Image

Fig. 3 | Configuring a Nexus 4 smartphone AVD for Android 4.3.

to more precisely match the hardware configuration of your device.

4. We also configured Android 4.3 AVDs that represent Nexus 7 by Google and Nexus 10 by Google for testing our tablet apps. Their settings are shown in Fig. 4. In addition, we configured Android 4.4 AVDs for the Nexus 4, Nexus 7 and Nexus 10 with the names: AVD_for_Nexus_4_KitKat, AVD_for_Nexus_7_KitKat, and AVD_for_Nexus_10_KitKat,

Image

Fig. 4 | Configuring Nexus 7 and Nexus 10 tablet AVDs.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.142.199.181