Compile and run the android Simulator

Source: Internet
Author: User

Lunch SDK-Eng

Make SDK-J2

 

After compilation, the SDK is installed in the following directory.

Android/DIR/out/host/linux-x86/SDK

There is a compressed package under this Directory, which is the SDK package we downloaded from eclipse.

If you have done app development, 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 simulators.

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

First, check the ID of the current SDK 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

-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 &

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, usually, file systems are stored on Block devices, that is, hard disks or flash. A linux root file system usually contains the following content:

USR: the largest directory that stores applications and files.

Bin: common command directory

ETC: system-related configuration file directory

Dev: System Device directory

OPT: Additional Software Directory installed on the host

Boot: stores the configuration files that must be read when the system starts, including the core (kernel ).

Home: Home Directory of common users

Lib: system usage library directory

VaR: log file directory

Lost + found: when the system is abnormal and an error occurs, some lost fragments are stored in this directory.

MNT: mount point directory for peripherals

Proc: Virtual File directory, which is the ing of system information

Root: root user's home directory

Sbin: directory of the Super command

TMP: the place where files are temporarily placed by a general user or a program being executed

Ramdisk. the IMG image is actually a package image of the preceding directory and some basic configuration files. ramdisk loads the image into the memory and uses the memory as a block device (hard disk, so normally ramdisk. IMG is usually relatively small. Of course, in addition to the above FHS standard Linux File System directory, the android system also adds the data and System directories.

The preceding userdata. IMG and system. IMG images are actually mounted to the data and System directories.

We can use the following command to specify the simulator, which kernel to start, and which file systems to use:

. /Emulator-AVD mydroid-system androiid_dir/out/target/product/generic/system. IMG-data androiid_dir/out/target/product/generic/userdata. IMG-ramdisk androiid_dir/out/target/product/generic/ramdisk. IMG-kernel androiid_dir/prebuilt/Android-arm/kernel/kernel-qemu-armv7
-System: Specify system. IMG.

-Data: Specify userdata. img

-Ramdisk: ramdisk. img

-Kernel: Specify the kernel Image

Experiment: slimming the androd System

The apps displayed in the Android system drawer are stored in the out/target/product/system/APP directory. we can delete some infrequently used and unwanted APK files, to reduce the size of Android, and to speed up the system startup, because when the system is started, the APK file under the system/APP directory will be scanned to compare whether there is any installation update.

Delete some APK, remove calculator, calendar, phone, SMS

$ Rm-F androiid_dir/out/target/product/system/APP/calculator .*

$ Rm-F androiid_dir/out/target/product/system/APP/calendar .*

$ Rm-F androiid_dir/out/target/product/system/APP/email .*

$ Rm-F androiid_dir/out/target/product/system/APP/message .*

$ Rm-F androiid_dir/out/target/product/system/APP/telephone .*

After deletion, execute the following command to compile system. IMG, instead of checking the dependency, so that the compilation can be completed soon.

$ Make Snod

Note: Make sure that the above two steps have been executed after source buile/envsetup. SH and lunch full-Eng are executed.

Snod indicates compiling system imge no dependency.

Then, restart the simulator and specify your own compiled system. IMG to check whether the app we deleted is in the drawer.

. /Emulator-AVD mydroid-system androiid_dir/out/target/product/generic/system. IMG-data androiid_dir/out/target/product/generic/userdata. IMG-ramdisk androiid_dir/out/target/product/generic/ramdisk. IMG-kernel androiid_dir/prebuilt/Android-arm/kernel/kernel-qemu-armv7

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.