Compiling and running the Android4.0 simulator

Source: Internet
Author: User

1. Build Android Simulator

Under Ubuntu, we can compile our own simulator and SDK in the source code, which, of course, does not look any different from the downloads in Windows.

The steps to compiling the Android emulator are similar to the build Android system:

Øsource build/envsetup.sh

Ølunch Sdk-eng

Ømake SDK

Every time you execute make, the compilation system automatically verifies the last compilation and this compilation, and if two times is different, it will delete all the target code, actually./build/core/main.mk

# This is allows us to force a clean build-includedafter the Config.make

The # Environment setup is done, but before we generateany dependencies. This

# file does the RM-RF inline so deps which areall do below would

# be generated correctly

Include $ (build_system)/cleanbuild.mk

We'll comment on line 75th so that we don't automatically recompile the last compiled intermediate code every time.

After compiling, the effect is shown in the following illustration:

The SDK is installed in the following directory:

Working_directory/out/host/linux-x86/sdk

In this directory there is a compressed package, which is the SDK package that we update to download the specified target from eclipse.

If you have done app development, you will know that we only have to download different versions of the SDK before we can create a different version of the emulator. Once we have compiled the SDK, we can create and run the ANDROID4.0 emulator.

$ CD Working_directory/out/host/linux-x86/sdk/android-sdk_eng.linux_linux-x86/tools

First, look at the ID number of the currently compiled SDK to create an emulator:

$./android list targets

Available Android Targets:

----------

Id:1 or "android-14"

Name:android 4.0

Type:platform

API level:14

Revision:2

skins:wxga800, WQVGA400, WXGA720, HVGA, WVGA854, WQVGA432, WVGA800 (default), QVGA,WSVGA

Abis:no ABIs.

Create an Emulator

$./android Create Avd-n mydroid-t 1

Note:-n indicates the name of the specified emulator,-T indicates the version ID to which the impersonation was created

Start simulator

$./EMULATOR-AVD Mydroid &

Because the simulator is going to start the Android system, it will use several image files, respectively: Kernel-qemu, System.img, userdata.img, ramdisk.img

Økernel-qemu: Kernel image file, which is a kernel file compiled by the Linux operating system for the QEMU emulator, which has the emulation hardware driver for QEMU, and if you are porting Android to a development board or mobile phone in the future, The first step is to make a kernel to support the Development Board or mobile phone.

Øsystem.img: Is the Android file system that contains the Android apps (APK), the various libraries (jars, so, a) and resources, configuration files (etc), system commands (Bin,usr/bin, XBin) , the image file is generated by the Out/target/product/product/system directory, and we can customize the contents of the directory, for example, if you want the Android system to install an application by default, Then you can copy the APK file that you want to install to the Out/target/product/product/system/app directory

ØUSERDATA.IMG: User data image, which contains program installation information, such as Windows C:/Program files/directory

O RAMDISK.IMG: Memory disk image, this file for people who have not done Linux porting, it is not easy to understand, the Linux kernel to boot up, to mount a file system as its own root file system, usually file system is stored on a block device, that is, the hard disk or flash, which contains the Linux kernel boot Some of the programs and configuration files that are dependent on the process, and the userdata.img and system.img images described earlier, are mounted on the Linux system's Data,system directory when it is started.

We can specify the Android emulator to load the specified image file by using the following script run_emulator.sh:

#!/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: Environment variable must be specified, emulator is to find all image files from the environment variable

-kernel: Specify kernel image

Of course, you can specify each image file individually, using 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 Specify RAMDISK.IMG

If you want to run the ADB shell Connection simulator in the future, we will have to use root permissions, otherwise: Error:device not found error.

Through the launch of the Android system->system settings->about phone, we can know that the use of our own compiled kernel started.

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.