1 Supported Operating Systems
The following operating systems are supported:
• Windows XP* (32-bit), Vista* (32- or 64-bit), or Windows 7* (32- or 64-bit)
• Mac OSX* (32- or 64-bit)
• Linux* (Ubuntu, Fedora); GNU C Library (glibc) 2.7 or later is required.
• On Ubuntu Linux, version 8.04 or later is required.
• On Fedora, target versions are F-12 and higher.
• 64-bit distributions must be capable of running 32-bit applications.
2 Hardware Requirements
The Android SDK requires disk storage for all of the components that you choose to install. Additional disk space is required to run the emulator, for example, to create SD cards for the Android Virtual Devices (AVDs).
3 Installing the JDK
At minimum, Java* JDK 5 or JDK 6 is required by the SDK. JDK 7 is also supported. JRE (Java Runtime Environment) alone is not sufficient. If your system does not have JDK 5, 6, or 7 installed, you can download JDK SE 7 from http://www.oracle.com/technetwork/java/javase/downloads/index.html and install it on your system.
4 Installing Eclipse*
Using the SDK with Eclipse* to develop Android applications is highly recommended. You can go to http://www.eclipse.org/downloads/ to download or update Eclipse. We suggest using the following Eclipse setups to develop Android Applications for Intel Architecture:
• Eclipse 3.5 (Galileo) or greater
• Eclipse Classic (versions 3.5.1 and higher)
• Android Development Tools Plugin (recommended)
5 Installing Apache Ant (Optional)
Developing Android applications using an integrated development environment such as Eclipse is highly recommended. But as an alternative, Apache Ant can be used to work with the SDK to build Android applications. You can visit http://ant.apache.org/ to download the binary distributions and install Ant. To work with the SDK, Ant 1.8 or later is required.
6 Downloading the SDK Starter Package and Adding the SDK Components
You can download the SDK Starter Package at http://developer.android.com/sdk/index.html. The SDK Starter Package does not include the platform-specific components you need to develop Android applications. It only provides the core SDK tools for you to download the rest of the platform components.
After installing the SDK Starter Package, run the Android SDK and AVD Manager.
• On Windows, select Start > All Programs > Android SDK Tools > SDK Manager
• On Linux, run your-android-sdk-directory/tools/android
In the Android SDK and AVD Manager dialog box, in the left panel, select Available packages, and in the right panel, click and expand the Android Repository node and select the packages to install, as shown in Figure 5.1.
Please note: you may see an error message displayed if you attempt to download from behind a firewall. If this occurs, please try again from outside the firewall.
If you still see an error message, close the SDK Manager, then right-click it in the Start menu and select Run as administrator. These two steps will resolve most error messages you may see when attempting to download.
7 Setting Up Eclipse to Work with the SDK
If you use the Eclipse IDE to develop software, we highly recommend you install and set up the Android Development Tool (ADT) Plugin.
7.1 Installing the ADT Plugin for Eclipse
To install the ADT Plugin for Eclipse, follow these steps:
1. Start Eclipse, select Help > Install New Software in the Install dialog box, and click the Add button.
2. In the Add Repository dialog box, enter “ADT Plugin” in the Name field and enter “https://dl-ssl.google.com/android/eclipse/” in the Location fields, as shown in Figure 5.2, and then click OK.
Figure 5.2 Repository Dialog Box
3. It will go back to the Install dialog box, connect to the Google repository server, and display the available ADT packages, as shown in Figure 5.3.
Figure 5.3 ADT Package List
4. Select next, accept the license agreement, and select Finish.
5. Restart Eclipse at this point.
7.2 Configuring the ADT Plugin
To configure the ADT Plugin, follow these steps:
1. Start Eclipse and select Windows > Preferences
2. In the Preferences dialog box, select Android from the left panel. On the right panel, use the Browse button to navigate to your Android SDK installation directory and click Apply. A list of SDK Targets you have installed will show up. At this point, click OK.
Figure 5.4 Preferences Dialog Box
After going through the steps described above, you will have the necessary tools available to start Android for Intel Architecture development. You now have everything you need to write your first app, but it would probably be best to also install the Intel® Architecture (x86) Emulator at this time, so that you can test your app as soon as it is ready. This next section will take you through the Intel Architecture (x86) Emulator install. We will discuss building an emulator image with AOSP sources, and emulating the resulting system images for x86. Some new features introduced in Gingerbread* and Ice Cream Sandwich* will also be discussed.
Overview of Android Virtual Device Emulation
Android runs on a variety of form factor devices with different screen sizes, hardware capabilities, and features. A typical device has a multitude of software (Android API) and hardware capabilities like sensors, GPS, camera, SD card and multitouch screen with specific dimensions.
The emulator is quite flexible and configurable with different software and hardware configuration options. Developers can customize the emulator using the emulator configuration called Android Virtual Device (AVD). AVD can be thought of as a set of configuration files that specify different Android software and device hardware capabilities. The Android Emulator uses these AVD configurations to configure and start the appropriate Android virtual image on the emulator.
As documented on the Android Web site (http://developer.android.com/guide/developing/devices/index.html), a typical AVD configuration has
- A hardware profile that specifies all the device capabilities (examples: camera, sensors).
- A System image, which will be used by the emulator for this AVD (API level to target, such as Gingerbread or Honeycomb).
- A Data image that acts as the dedicated storage space for user’s data, settings, and SD card.
- Other options including emulator skin, the screen dimensions, and SD card size.
Developers are encouraged to target different API levels, screen sizes, and hardware capabilities (such as camera, sensors, and multitouch). The AVD configuration can be used to customize the emulator as needed. Developers can create as many AVDs as desired, each one targeting a different Intel architecture–based Android device: for example, a developer can create an Intel architecture–based Gingerbread AVD with a built-in skin like WVGA800, or a custom one manually specifying the screen resolution to be used.
The Android SDK has supported Intel architecture–based Android Emulation since version r12. The SDK integrates this support into all developer tools including the eclipse ADT plugin. Figure 5.6 is a sample screenshot of the Android Emulator for x86 running Gingerbread. The model number is highlighted, and shows “Full Android on x86 Emulator.”
Figure 5.5 Android emulator
For detailed instructions on how to use the emulator, please refer to the following Android documentation: http://developer.android.com/guide/developing/devices/emulator.html.
9. What Emulator Should You USe?
At the time of this writing, there are two emulator images available for Intel architecture (x86): one for Android 2.3.7 (Gingerbread), and one for Android 4.0.4 (Ice Cream Sandwich).
While there are many advantages to developing for the latest Android operating system release, many developers prefer to target Android 2.x, as a majority of Android phones in use today do not yet run Android 4.x or higher (in the US, only 1 in 5 Android phones run ICS or higher at the time of this writing). This percentage will change over time, so it is strongly suggested that you keep market conditions in mind when determining your target operating system.
For more Gingerbread-specific operating system information, the following article may prove useful: http://blogs.computerworld.com/17479/android_gingerbread_faq.
For Ice Cream Sandwich information, use this article: http://www.computerworld.com/s/article/9230152/Android_4.0_The_ultimate_guide_plus_cheat_sheet_.
10. Why Use The Emulator
First of all, it’s free. The Android SDK and its third-party add-ons cost absolutely nothing and allow developers to emulate devices that they do not own and may not have access to. This is important as not all phones acquire the latest Android OS versions via Over The Air (OTA) updates, and it may not be feasible for developers to purchase every device that is expected to support their software package(s).
Development and Testing. Developers can use the SDK to create several Android* Virtual Device (AVD) configurations for development and testing purposes. Each AVD can have varying screen dimensions, SD card sizes, or even versions of the Android SDK (which is useful for testing backward compatibility with prior Android builds).
Playing with a new build. The emulator allow developers to just have fun with a new build of Android and learn more about it.
Let’s now walk through the steps required to build and run an emulator image on an x86 build. For simplicity’s sake, this section will focus on the Gingerbread emulator, though most of this content will apply to the Ice Cream Sandwich emulator as well.
11 Building an Emulator Image
The first step will be to follow the setup instructions listed here: http://source.android.com/source/initializing.html.
Google* has made Gingerbread sources available at a new location. The documentation at http://source.android.com/source/downloading.html has been updated to reflect these changes.
Currently, the default repo initialization instructions are only for getting the latest master branch or a specific branch such as when using the command android-2.3.7_r1. The repo and branch instructions for building Gingerbread x86 Emulator images were not given.
Please use the branch label gingerbread to download the latest Android source branch, as shown in Figure 5.6. This branch has the required build files and modules needed to build the x86 SDK Emulator images.
Figure 5.6 Gingerbread branch
Initialize the build env, as shown in Figure 5.7:
Figure 5.7 Initialization
Use the lunch command to configure the build for building the x86 SDK, as shown in Figure 5.8. This will build the emulator images for x86, along with other SDK modules.
Figure 5.8 Lunch command
Finally, issue the make command make sdk to kick off the build, as shown in Figure 5.9.
Figure 5.9 Make sdk command
Additionally, you can specify the number of parallel jobs for make using the –j parameter, to speed up the build process. (It is recommended that you use a value that is at least equal to or greater than the total number of CPUs in the system.)
The build will create three images, including the QEMU Android kernel image:t system.img (Android), userdata.img, and ramdisk.img.
When the build completes, the images will be in the build folder $ANDROID_BUILD_TOP/out/target/product/generic_x86/ - as shown in Figure 5.10.
Figure 5.10 Image location
The Android kernel image for QEMU (kernel-qemu) comes with Android Sources. It is located under the prebuilt folder ($ANDROID_BUILD_TOP/prebuilt/android-x86/kernel), as shown in Figure 5.11.
Figure 5.11 Kernel image
You now have all the image files required for running an x86 Android Gingerbread image on the Android x86 Emulator. The image files will need to be set up with the SDK, which will be covered in next section.
12. Setting Up the SDK to USe x86 Emulator Images
The Android SDK tools (android, the AVD manager) expect the x86 emulator images to be present in the default SDK folders for platform images /platforms/android-10/images.
The screenshots in the following figures assume the $ANDROID_SDK_TOP environment variable is set to the location of the Android SDK installation folder.
Figure 5.12 Image location
As in Figure 5.12, by default, Android-10 comes with emulator images for ARM. In order to set up the x86 emulator images in the SDK, you need to create an x86 folder and copy the images you build into the folder. You can also move the ARM images to their own folder as shown in Figure 5.13.
Figure 5.13 ARM folder
Figure 5.14 shows instructions for the x86 folder.
Figure 5.14 x86 instructions
The final images folder of the Android-10 platform is shown in Figure 5.15.
Figure 5.15 Final images folder
Before using the Gingerbread Intel architecture images with the x86 Emulator, you must create an AVD configuration that specifies the required software and hardware customizations. More detailed information about AVDs can be found below, and in the Intel Developer Zone article “Android* Virtual Device Emulation for Intel® Architecture.”
At this point, your emulator and x86 image are ready to use. Please note that the emulator performance will see drastic improvements if you use Intel Hardware Acceleration Execution Manager (Intel HAXM) in conjunction with this system image—without it, performance may vary. (Intel HAXM requires an Intel processor with Intel VT-x support. For more information about Intel HAXM, visit http://int-software.intel.com/en-us/android.)
It is now time to use the Gingerbread x86 emulator to emulate an x86 image.
Open the Android tool or bring up the AVD creation tool directly from Eclipse.
Figure 5.16 and Figure 5.17 show the creation of an AVD for Gingerbread with an Intel® Atom™ (x86) CPU.
Figure 5.16 New AVD creation
Figure 5.17 Success dialog box
Figure 5.18 Launch options
Figure 5.19 shows the home screen of the Gingerbread for Intel Atom (x86) on emulator-x86.
Figure 5.19 Home screen
Figure 5.20 shows the About Phone view of the settings.
Figure 5.20 About phone view
It is recommended that you use the x86 emulator with Intel® VT hardware acceleration. On Linux, this can be done using the Linux KVM. Ubuntu has further documentation on how to configure and use it: https://help.ubuntu.com/community/KVM.
Figure 5.21 KVM
With KVM, shown in Figure 5.21, (-enable-kvm) users will likely notice performance boosts during Android boot along with quicker emulator responsiveness.
13. Sample Gingerbread Feature: Battery Usage Stats
About Phone there is a Battery Use section. Battery stats will vary based on the emulation device and build. In the case where the developer can telnet into the emulated device, some simple commands can be used to mock battery drain. Take a look at one such example: http://android-er.blogspot.com/2010/09/how-to-set-battery-status-of-android.html.
14. Sample Gingerbread Feature: Task Manager
In Settings > Applications > Running Services, there is a Running tab, which shows what’s currently running, as shown in Figure 5.22.
Figure 5.22 The Task Manager
For example, the developer can close Settings process by clicking on the item and selecting Stop.
15. Sample Gingerbread Feature: Cut and Paste Text
Opening the Messaging application and choosing New Message allows the user to type a message as if sending an SMS. By clicking in the text field and typing on the host keyboard, characters appear seamlessly on the Android screen. After typing “Hello 2.3.5!” the screen looks like Figure 5.23.
Figure 5.23 Messaging Fun
By dragging the mouse into the text field where “Hello 2.3.5!” is found and holding down the mouse button (or touchpad button) for about 2 seconds, a tool tip menu appears to Edit Text. Choosing, Select all and then repeating the mouse operation, the user sees the option to cut the text. After cutting text, repeating the mouse operation once again allows the user to paste back the text.
16. Ice Cream Sandwich Emulation
The x86 Android 4.0.4 emulator system image enables you to run an emulation of Android Ice Cream Sandwich on your development machine. In combination with the Android SDK, you can test out your Android applications on a virtual Android device based on Intel architecture (x86).
In order to install the emulator system image, you can use the Android SDK Manager (recommended method), or you can download the binary zip file and unzip and copy the included directory into the add-ons directory of your Android SDK installation. (Note that this method does not allow for automatic updates of the add-on).
17. Installation Guide
The following section will provide a guide for ICS image installation.
The Android x86 Emulator Image requires the Android SDK to be installed. For instructions on installing and configuring the Android SDK, refer to the Android developer website (http://developer.android.com/sdk/).
Optional: The x86 Emulator Image for Android can be accelerated using Intel® Hardware Accelerated Execution Manager (Intel HAXM). For more information, please refer to the chapter on Intel HAXM.
17.2 Downloading through the Android SDK Manager
1. Start the Android SDK Manager.
2. Under Android 4.0.4 (some screenshots may refer to older versions), select Intel x86 Atom System Image, as shown in Figure 5.24.
Figure 5.24 Intel x86 Atom system image
1. Once selected, click the Install Package button.
2. Review the Intel Corporation license agreement. If you accept the terms, select Accept and click Install.
3. The SDK Manager will download and extract the system image to the appropriate location within the Android SDK directory.
17.3 Using the System Image
1. Start the Android AVD Manager and create a new AVD, setting Target to Android 4.0.X, and CPU/ABI to Intel Atom (x86), as shown in Figure 5.25.
Figure 5.25 Setting the target
Note: if the Intel Atom (x86) CPU/ABI option is not available, please make sure that the system image is installed correctly.
1. Click the Create AVD button.
2. The AVD has been successfully created and is now ready to use, as shown in Figure 5.26.
Figure 5.26 Image ready
17.4 Downloading Manually
1. Go to http://www.intel.com/software/android.
2. Download the Intel x86 Atom System Image (found under the Tools and Downloads tab).
3. Navigate to the directory containing the Android SDK, as shown in Figure 5.27.
Figure 5.27 Android SDK directory
1. The system-images directory contains Android system images, separated by architecture, as shown in Figure 5.28.
Figure 5.28 Separated images
1. Expand android-15 (this directory contains API Level 15 system images), shown in Figure 5.29.
Figure 5.29 API level 15
1. Extract the x86 directory contained in the downloaded system image archive directly into the android-15 directory.
2. The directory structure should now look like Figure 5.30.
Figure 5.30 Expected structure
1. The system image is now installed and ready to be used.
17.5 CPU Acceleration
The performance of Intel Atom x86 Image for Android Ice Cream Sandwich can be improved using hardware-based virtualization using Intel VT-x technology.
If your computer has an Intel processor with VT-x support, it is recommended that Intel Hardware Acceleration Execution Manager (Intel HAXM) be used in conjunction with this system image. For more information about Intel HAXM, visit http://int-software.intel.com/en-us/android.
Note: Intel HAXM is for Windows and OS X operating systems only. For Linux hosts, Kernel-based Virtual Machine (KVM) can be used to accelerate emulation performance. For information on installing and configuring KVM on Ubuntu, refer to the following guide: https://help.ubuntu.com/community/KVM/Installation.
17.6 GPU Acceleration
The Intel Atom x86 Image for Android Ice Cream Sandwich can make use of hardware GPU features to increase the performance of games, graphics-intensive programs, and user interface elements.
Note: The functionality and performance of GPU acceleration is highly dependent on your computer’s graphics card and graphics drivers.
To use hardware GPU acceleration, perform the following steps:
1. Open the Android AVD Manager.
2. Select the AVD, and click Edit.
3. The AVD editor window will appear. In the Hardware section, click New, as shown in Figure 5.31.
Figure 5.31 Hardware section
1. In the Property dropdown box, select GPU Emulation, as shown in Figure 5.32.
Figure 5.32 GPU emulation
1. Click OK.
2. After the GPU Emulation property has been added, change the Value to yes, as shown in Figure 5.33.
Figure 5.33 Value changed to yes
1. Click Edit AVD to save the AVD.
2. After the AVD has been modified, a dialog box will appear confirming the AVD settings, shown in Figure 5.34.
Figure 5.34 Confirmation dialog box
In the confirmation dialog box, the hw.gpu.enabled=yes line indicates that GPU acceleration is enabled for that particular AVD.
Note: The GPU acceleration must be enabled on a per-AVD basis.