Android system migration and platform development-compile and run the android4.0 Simulator

Source: Internet
Author: User

Author: Tang Pan, Hua Qing vision embedded training lecturer.

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. (Android SDK Development Environment)

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

Ø 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

[Plain] view plaincopyprint?

1. 71 # This allows us to force a clean build-your dedafter the config. Make
2. 72 # environment setup is done, but before we generateany dependencies. This
3. 73 # file does the RM-RF inline so the deps which areall done below will
4. 74 # be generated correctly
5. 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:

[Plain] view plaincopyprint?

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

[Plain] view plaincopyprint?

1. $ CD working_directory/out/host/linux-x86/SDK/android-sdk_eng.linux_linux-x86/tools

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

[Plain] view plaincopyprint?

1. $./Android list targets
2. Available Android targets:
3 .----------
4. ID: 1 or "Android-14"
5. Name: Android 4.0
6. Type: Platform
7. API level: 14
8. Revision: 2
9. skins: wxga800, wqvga400, wxga720, hvga, wvga854, wqvga432, wvga800 (default), qvga, wsvga
10. Abis: No Abis.

Create a simulator

[Plain] view plaincopyprint?

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

[Plain] view plaincopyprint?

1. $./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/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/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:

[Plain] view plaincopyprint?

1 .#! /Bin/bash
2. pwd_path = 'pwd'
3. img_path = $ pwd_path/out/target/product/generic
4. exportpath = $ pwd_path/out/host/linux-x86/SDK/android-sdk_eng.linux_linux-x86/tools: $ path
5. exportandroid_product_out = $ pwd_path/out/target/product/generic
6. Export android_swt = $ pwd_path/out/host/linux-x86/framework
7. 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:

[Plain] view plaincopyprint?

1. $ emulator-kernel $ pwd_path/kernel/goldfish/ARCH/ARM/boot/zimage \
2.-image $ img_path/system. IMG \
3.-Data $ img_path/userdata. IMG \
4.-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: 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.

Recommended reading:Android system migration and platform development-Prepare the android Development Environment

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.