Building an Emulator Image
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 are not given. Please use the branch label
gingerbread to download the latest Android source branch, as shown in Listing One. This branch has the required build files and modules needed to build the x86 SDK emulator images.
$ repo init –u https://android.googlesource.com/platform/manifest -b gingerbread $ repo sync
Initialize the build environment, as shown in Listing Two.
$ source build/envsetup.sh including device/htc/passion/vendorsetup.sh including device/samsung/crespo4g/vendorsetup.sh including device/samsung/crespo/vendorsetup.sh
lunch command to configure the build for building the x86 SDK, as shown in Listing Three. This will build the emulator images for x86, along with other SDK modules.
$ lunch sdk_x86-eng ===================================================== PLATFORM_VERSION_CODENAME=REL PLATFORM_VERSION=2.3.7 TARGET_PRODUCT=sdk_x86 TARGET_BUILD_VARIANT=eng TARGET_SIMULATOR=false TARGET_BUILD_TYPE=release TARGET_BUILD_APPS= TARGET_ARCH=x86 TARGET_ARCH_VARIANT=x86_atom HOST_ARCH=x86 HOST_OS=linux HOST_BUILD_TYPE=release BUILD_ID=GINGERBREAD =====================================================
Finally, issue the make command
make sdk in order to kick off the build, as shown in Listing Four.
$ make sdk<br /> ===================================================== PLATFORM_VERSION_CODENAME=REL PLATFORM_VERSION=2.3.7 TARGET_PRODUCT=sdk_x86 TARGET_BUILD_VARIANT=eng TARGET_SIMULATOR=false TARGET_BUILD_TYPE=release TARGET_BUILD_APPS= TARGET_ARCH=x86 TARGET_ARCH_VARIANT=x86_atom HOST_ARCH=x86 HOST_OS=linux HOST_BUILD_TYPE=release BUILD_ID=GINGERBREAD =====================================================
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:
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 2.
Figure 2: Image location in $ ls $ANDROID_BUILD_TOP/out/target/product/generic_x86/ -Altr.
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 3.
Figure 3: Kernel image located in $ ls $ANDROID_BUILD_TOP/prebuilt/android-x86/kernel -Altr.
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 next.
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 following figures assume the
$ANDROID_SDK_TOP environment variable is set to the location of the Android SDK installation folder.
Figure 4: Image location in $ cd $ANDROID_SDK_TOP/platforms/android-10/images/ $ls -l.
As in Figure 4, 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 Listing Five.
$ mkdir arm $ mv *.img kernel-qemu arm/
Listing Six shows instructions for the x86 folder.
$ mkdir x86 $ cp $ANDROID_BUILD_TOP/out/target/product/generic_x86/*img x86/ $ cp $ANDROID_BUILD_TOP/prebuilt/android-x86/kernel/kernel-qemu x86/ $ cp NOTICE.txt arm/ $ cp NOTICE.txt x86/
The final images folder of the Android-10 platform is shown in Figure 5.
Figure 5: Final images folder $ ls –l *.