Compile and run the Android4.0 Simulator

Source: Internet
Author: User

1. Compile the Android Simulator

In Ubuntu, We can compile our own simulators, sdks, and other compilation tools in the source code. Of course, this is no different from the download in windows.

The steps for compiling the Android simulator are similar to those for compiling the Android system:

Source build/envsetup. sh

Ø lunch sdk-eng

Ø make sdk

Each time you execute make, the compilation system automatically verifies the last compilation item and the current compilation item. If the two compilation items are different, all the target code will be deleted. /build/core/main. mk

71 # This allows us to force a clean build-your dedafter the config. make

72 # environment setup is done, but before we generateany dependencies. This

73 # file does the rm-rf inline so the deps which areall done below will

74 # be generated correctly

75 include $ (BUILD_SYSTEM)/cleanbuild. mk

We will comment out the 75th lines so that the intermediate code of the previous compilation will not be automatically deleted every time and re-compiled.

Shows the effect after compilation:

The sdk is installed in the following directory:

WORKING_DIRECTORY/out/host/linux-x86/sdk

There is a compressed package under this Directory, which is the sdk package we updated from eclipse to download the specified Target.

If you have developed an app, you will know that we can create Simulators of different versions only after downloading sdks of different versions. After compiling the sdk, we can create and run the simulator of Android4.0.

$ Cd WORKING_DIRECTORY/out/host/linux-x86/sdks/android-sdk_eng.linux_linux-x86/tools

First, check the currently compiled sdk ID to create a simulator:

$./Android list targets

Available Android targets:

----------

Id: 1 or "android-14"

Name: IOS 4.0

Type: Platform

API level: 14

Revision: 2

Skins: WXGA800, WQVGA400, WXGA720, HVGA, WVGA854, WQVGA432, WVGA800 (default), QVGA, WSVGA

ABIs: no ABIs.

Create a simulator

$./Android create avd-n mydroid-t 1

Note:-n indicates the name of the specified simulator, and-t indicates the id of the version used to create the simulation.

Start the simulator

$./Emulator-avd mydroid &

Since the simulator needs to start the android system, it needs to use several image files: kernel-qemu, system. img, userdata. img, ramdisk. img

Ø kernel-qemu: kernel image file. It is the kernel file compiled by the linux operating system for the qemu simulator. It contains the qemu simulation hardware driver, if android is transplanted to the Development Board or mobile phone in the future, the first step is to make a kernel that supports the development board or mobile phone.

Ø system. img: The file system of the android system, which contains the android system application (apk), various libraries (jar, so, a) and resources used by the system, configuration file (in the etc directory), system command (bin, usr/bin, xbin), which is packaged and generated by the out/target/product/PRODUCT/system directory, we can customize the items in this directory. For example, if you want to make the android system install an application by default, you can copy the apk file to the out/target/product/PRODUCT/system/app directory.

Ø userdata. img: user data image, containing Program installation information, such as windows C:/Program Files/directory

Ø ramdisk. img: memory disk image. This file is hard to understand for those who have not transplanted Linux. When the Linux kernel is started, a file system should be mounted as its root file system, generally, file systems are stored on Block devices, that is, hard disks or flash files, which contain some programs and configuration files that Linux kernel depends on during startup, as described above. img and system. the img image is mounted to its data and system directory after linux is started.

We can use the following script run_emulator.sh to specify the Android simulator to load the specified image file:

#! /Bin/bash

PWD_PATH = 'pwd'

IMG_PATH = $ PWD_PATH/out/target/product/generic

ExportPATH = $ PWD_PATH/out/host/linux-x86/sdk/android-sdk_eng.linux_linux-x86/tools: $ PATH

ExportANDROID_PRODUCT_OUT = $ PWD_PATH/out/target/product/generic

Export ANDROID_SWT = $ PWD_PATH/out/host/linux-x86/framework

Emulator-kernel $ PWD_PATH/kernel/goldfish/arch/arm/boot/zImage

Note:

ANDROID_PRODUCT_OUT: The environment variable must be specified. emulator searches for all the image files under this environment variable.

-Kernel: Specify the kernel Image

You can also specify each image file by running the following command:

$ Emulator-kernel $ PWD_PATH/kernel/goldfish/arch/arm/boot/zImage

-Image $ IMG_PATH/system. img

-Data $ IMG_PATH/userdata. img

-Ramdisk $ IMG_PATH/ramdisk. img

Note:

-System: Specify system. img.

-Data: Specify userdata. img

-Ramdisk: ramdisk. img

If you want to run the adb shell connection simulator in the future, you must use the root permission. Otherwise, the error: device not found will occur.

From the started Android System-> System Settings-> About phone, we can see that we use our own compiled kernel to start.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.