Channels ▼
RSS

Parallel

Android on x86: Understanding Android Device Emulation


Building an Emulator Image

The first step will be to follow the setup instructions. Google has made Gingerbread sources available at a new location. The documentation 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 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.

Listing One.

      $ repo init –u https://android.googlesource.com/platform/manifest   -b gingerbread
      $ repo sync

Initialize the build environment, as shown in Listing Two.

Listing Two.

      $ source build/envsetup.sh
      including   device/htc/passion/vendorsetup.sh
      including device/samsung/crespo4g/vendorsetup.sh
      including   device/samsung/crespo/vendorsetup.sh

Use the 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.

Listing Three.

      $ 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.

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: 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 2.

Android on x86 Field Guide
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.

Android on x86 Field Guide
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.

Android on x86 Field Guide
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.

Listing Five.

$ mkdir arm
$ mv *.img kernel-qemu arm/

Listing Six shows instructions for the x86 folder.

Listing Six.

$ 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.

Android on x86 Field Guide
Figure 5: Final images folder $ ls –l *.


Related Reading


More Insights






Currently we allow the following HTML tags in comments:

Single tags

These tags can be used alone and don't need an ending tag.

<br> Defines a single line break

<hr> Defines a horizontal line

Matching tags

These require an ending tag - e.g. <i>italic text</i>

<a> Defines an anchor

<b> Defines bold text

<big> Defines big text

<blockquote> Defines a long quotation

<caption> Defines a table caption

<cite> Defines a citation

<code> Defines computer code text

<em> Defines emphasized text

<fieldset> Defines a border around elements in a form

<h1> This is heading 1

<h2> This is heading 2

<h3> This is heading 3

<h4> This is heading 4

<h5> This is heading 5

<h6> This is heading 6

<i> Defines italic text

<p> Defines a paragraph

<pre> Defines preformatted text

<q> Defines a short quotation

<samp> Defines sample computer code text

<small> Defines small text

<span> Defines a section in a document

<s> Defines strikethrough text

<strike> Defines strikethrough text

<strong> Defines strong text

<sub> Defines subscripted text

<sup> Defines superscripted text

<u> Defines underlined text

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task. However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.

 
Disqus Tips To upload an avatar photo, first complete your Disqus profile. | View the list of supported HTML tags you can use to style comments. | Please read our commenting policy.
 

Video