After the Android development environment, the Android emulator is perhaps the most powerful and frequently used tool available to the Android app developer.
The Android emulator is a software tool that simulates how a real Android device behaves. Developers can build and deploy their applications to the emulator and then test and debug their applications, without the need for connecting real Android devices via USB. The benefits are immediately obvious:
- The developers can quickly and easily make code updates and run their code on a virtual device.
- Testers can later test on actually devices for adequate test coverage
This simplifies the hardware requirements for the development team and keeps the developer's desktop from becoming a nest of USB cables, tablets, smartphones and other Android devices. (This might happen anyway, but at least using an emulator will minimize how often you have to dive into the nest. You might even like that nest of devices and cables. :) )
How Is The Android Emulator Configured?
The Android emulator must be launched with an Android Virtual Device (AVD) configuration, which describes a specific type of device to simulate. You can customize your emulator to mimic a variety of Android devices, both real and imagined. You do this simply by creating different AVDs with the device specifications you desire. AVDs are created and managed using the Android SDK and AVD Manager, which is accessible from within Eclipse (see Figure 1).
Click here for larger image
Figure 1. Android SDK and AVD Manager
Some common AVD configuration details include:
- The Android SDK Target
- The SD Card Details
- Screen Size and Density
- Input Method Specifics (Touch Screens, Trackballs, Keyboards, DPads)
- Camera Features and Specifications
- RAM and Cache Settings
- Other Hardware and Sensor Features
There are numerous settings. For a complete list, see the Android SDK documentation regarding AVDs.
Figure 2 shows the Android emulator, when it is used with different AVDs.
Click here for larger image
Figure 2. Android Emulator with Many Different AVDs
How Do I Launch the Android Emulator?
The Android emulator is part of the tools that ship with the Android SDK. If you are using Eclipse as your development environment and have installed the Android Development Tools (ADT) plug-in, then you'll find it straightforward to get the emulator up and running. When you've gotten your application code compiled and ready to run within Eclipse, simply create a Debug configuration. You can set your application's debug configuration to target a specific AVD, or choose Manual mode and select an AVD on-the-fly. We prefer the Manual mode so we can always choose between running emulators or several USB connected devices.
When you choose to Debug from within Eclipse, the emulator is started with the AVD you chose, your application is installed (or updated), and you can begin to interact with the emulator and run your application. You can also launch any of the Android tools from the command line.
Tip: The emulator takes time to start up, so it's a good practice to keep it running on your development machine while you're working. When you choose to debug from Eclipse, your application will simply be updated immediately without the bother of relaunching the emulator.