Build Android platform-Zhuan http://mmmyddd.freeshell.net/wiki/android/build.html

Source: Internet
Author: User
Tags git commands

Top

Website

Android
The latest source code download official website is: http://source.android.com

Source code download instructions page is: http://source.android.com/download
(It seems that I cannot use it now)
The current website is http://git.android.com


Top

Create directory

Create the following directory structure in the home (/home/Justin) directory:

/Home/Justin/android
:
Total 36
Drwxr-XR-x 7 Justin 4096 01-15.
Drwxr-XR-x 58 Justin 12288 01-15 ..
Drwxr-XR-x 2 Justin 4096 01-15 applications
Drwxr-XR-x 2 Justin 4096 01-15 downloads
Drwxr-XR-x 2 Justin 4096 01-15 Bin
Drwxr-XR-x 2 Justin 4096 01-15 SDK
Drwxr-XR-x 2 Justin 4096 01-15 SRC
Drwxr-XR-x 2 Justin 4096 01-15 tools

Add the directory to the PATH environment variable:

export PATH=$HOME/android/bin:$PATH

If you need to use it repeatedly, you need to add this line ~ /. Bashrc Startup Script


Top

Donwload tool chaintop

Git

Git version above 1.5.4

sudo apt-get install git-core
Top

Proxy

Install agent software:

apt-get install connect-proxy



Top

Repo

Repo is a Python script that encapsulates git commands:

curl http://android.git.kernel.org/repo > ~/android/bin/repo

The curl proxy must be set inside the Gateway:

Assume that the (HTTP) proxy of the network segment is: wwwgate.freeshell.net: 8080

curl --proxy wwwgate.freeshell.net:8080 http://android.git.kernel.org/repo > ~/android/bin/repo

Add executable permissions

chmod a+x ~/android/bin/repo
Top

Python

Python version is later than 2.4

sudo apt-get install python
Top

JDK 1.6

Download from the following URL:
Http://java.sun.com/javase/downloads
Decompress the following file:
~ /Android
/Downloads/jdk-6u11-linux-i586.bin

cd ~/android/downloads
chmode a+x jdk-6u11-linux-i586.bin

Run this executable file and copy the generated directory jdk1.6.0 _ 11 to/usr/local /.

Add the following environment variables ~ /. Bashrc:

export PATH=/usr/local/jdk1.6.0_11/bin:$PATH
export JAVA_HOME=/usr/local/jdk1.6.0_11
export ANDROID_JAVA_HOME=$JAVA_HOME
Top

Other tools
sudo apt-get install gcc g++
sudo apt-get install flex bison gperf libsdl1.2-dev libesd0-dev libwxgtk2.6-dev /
build-essential zip curl libncurses5-dev zlib1g-dev valgrind libreadline5-dev

If the build fails due to the lack of X11/xatom. h and X11/xlib. H,
You can install the following package:

sudo apt-get install x11proto-core-dev  # provides Xatom.h
sudo apt-get install libx11-dev # provides Xlib.h
Top

Cross-compilation environment

Android
The default target code of emulator is the code of arm7. If you need to port the target code to another
The corresponding cross-compilation environment needs to be reconfigured when the version of the ARM platform is used.


Top

Download the Android platform source code

1. initialize the list of files to be downloaded:

cd ~/android/src
repo init -u git://android.git.kernel.org/platform/manifest.git

If you want to check out the code on other branches except the master node, you can use the-B option:

cd ~/android/src
repo init -u git://android.git.kernel.org/platform/manifest.git -b cupcake

2. Configure the GIT account

git config --global user.email "xxxxx@xxxxxxx"
git config --global user.name "xxxxxx"

3. Synchronization file list:

repo sync

After downloading all the code for the first time, you can update the subitem code by module:

repo sync project-path

The project-path can be found in src/. repo/manifests/Default. xml:

<?xml version="1.0" encoding="UTF-8"?>
<manifest>
<remote name="korg"
fetch="git://android.git.kernel.org/"
review="review.source.android.com" />
<default revision="master"
remote="korg" />

<project path="build" name="platform/build">
<copyfile src="core/root.mk" dest="Makefile" />
</project>

<project path="kernel"
name="kernel/common"
revision="refs/heads/android-2.6.27" />

<project path="bionic" name="platform/bionic" />

<project path="bootable/bootloader/legacy" name="platform/bootable/bootloader/legacy" />
<project path="bootable/diskinstaller" name="platform/bootable/diskinstaller" />
<project path="bootable/recovery" name="platform/bootable/recovery" />
... ...

You need to set a proxy for internal use of the Gateway:

Create the following file:

#!/bin/sh
# /home/justin/android/bin/socks-gw.sh
# This script connects to a HTTP proxy using connect.c
connect -H wwwgate.freeshell.net:8080 $@
#!/bin/sh
# /home/justin/android/bin/socks-ssh.sh
ssh -o ProxyCommand="/home/justin/android/bin/socks-gw.sh %h %p" $@

Add the executable permissions for these two files:

chmod a+x /home/justin/android/bin/socks-ssh.sh
chmod a+x /home/justin/android/bin/socks-gw.sh

Environment Variables of all proxies can be placed in:

#!/bin/sh
# /home/justin/proxy.sh

# http proxy setting
export HTTP_PROXY=http://wwwgate.freeshell.net:8080
export http_proxy=$HTTP_PROXY

# set git to use ssh over http proxy
export GIT_SSH="/home/justin/android/bin/socks-ssh.sh"
export GIT_PROXY_COMMAND="/home/justin/android/bin/socks-gw.sh"

Run as needed:

. ~/proxy.sh

Top

Compile the Android platform and SDK
Top

Fully compiled top

Compile the image
cd ~/android/src
make

After the image is compiled successfully, it will be in the directory

~/android/src/out/target/product/generic

To generate some image files.

Ramdisk. img
System. img
Userdata. img
Android
-Info.txt

Verify and run these modules:

export ANDROID_PRODUCT_OUT=/home/justin/android/src/out/target/product/generic
cd out/host/linux-x86/bin
./emulator
Top

SDK Compilation


After a complete compilation, you can build the SDK.

make sdk

Note: If you need to build the SDK, you need to install the sun-java5-jdk instead of the sun-java6-jdk, otherwise the following error will occur:

Build/CORE/product_config.mk: 207: Warning: adding test OTA key
========================================================== ====
Target_product = generic
Target_build_variant = ENG
Target_simulator =
Target_build_type = release
Target_arch = arm
Host_arch = x86
Host_ OS = Linux
Host_build_type = release
Build_id =
========================================================== ====
Combining notice files: Out/target/product/generic/obj/notice.txt
Finding notice files: Out/host/linux-x86/obj/notice_files/hash-Timestamp
Combining notice files: Out/host/linux-x86/obj/notice.txt
Package: Out/target/product/generic/generic-img-eng.justin.zip
SDK buildinfo: Out/target/product/generic/SDK/sdk-build.prop
Docs droiddoc: Out/target/common/docs/dx
Javadoc: Error-in the doclet droiddoc class, java. Lang. Reflect. invocationtargetexception has been thrown by the method start.
Com. Sun. Tools. javac. Code. symbol $ completionfailure: the class file of sun. util. Resources. openlistresourcebundle is not found.

At this point, you can consider reinstalling sun jdk5, or directly from the http://java.sun.com/javase/downloads
Download ~ /Android
/Downloads/jdk-1_5_0_17-linux-i586.bin

sudo apt-get install sun-java5-jdk

Set the. bashrc command.

After the SDK is compiled successfully ~ /Android
/Src/out/host/linux-x86/SDK/
Generate SDK file directories and packages:

Android
Sdk_eng.justin_linux-x86
Android
-Sdk_eng.justin_linux-x86.zip

And in ~ /Android
Package all the image files under/src/out/target/product/generic (generic is the default product name:

Generic-img-eng.justin.zip

The generated SDK directory structure is:

/Home/Justin/Android/src/out/host/linux-x86/SDK/android-sdk_eng.justin_linux-x86:
Total 32
Drwxrwx --- 6 Justin 4096 02-13.
Drwxr-x --- 3 Justin 4096 02-13 ..
Drwxrwx --- 2 Justin 4096 02-13 add-ons
Drwxrwx --- 14 Justin 4096 02-13 docs
-RW ---- 1 Justin 172 02-13 documentation.html
Drwxrwx --- 3 Justin 4096 02-13 platforms
-RW ---- 1 Justin 225 02-13 release_notes.txt
Drwxrwx --- 3 Justin 4096 02-13 tools

To install the generated SDK, you only need to add:

export PATH=$PATH:/home/justin/android/src/out/host/linux-x86/sdk/android-sdk_eng.justin_linux-x86/tools

Link the generated SDK directory to ~ for ease of use ~ /Android
/SDK:

ln -sf /home/justin/android/src/out/host/linux-x86/sdk/android-sdk_eng.justin_linux-x86/tools /
~/android/sdk

Top

Module Compilation

Run the following command in the src directory:

cd ~/android/src
. build/envsetup.sh

Envsetup. Sh provides some bash function definitions. After running envsetup. Sh, you can use help
Command to view:

help

Get the help information of these commands:

Invoke ". build/envsetup.sh" from your shell to add the following functions to your environment:
- croot: Changes directory to the top of the tree.
- m: Makes from the top of the tree.
- mm: Builds all of the modules in the current directory.
- mmm: Builds all of the modules in the supplied directories.
- cgrep: Greps on all local C/C++ files.
- jgrep: Greps on all local Java files.
- resgrep: Greps on all local res/*.xml files.

Look at the source to view more functions. The complete list is:
add_lunch_combo cgrep check_product check_variant choosecombo chooseproduct choosetype choosevariant croot findmakefile gd
bclient get_abs_build_var getbugreports get_build_var getprebuilt gettop help isviewserverstarted jgrep lunch m mm mmm pid
printconfig print_lunch_menu resgrep runhat runtest setpaths set_sequence_number set_stuff_for_environment settitle smoke
test startviewserver stopviewserver tapas tracedmdump

The compilation of modules is helpful for commands such as tapas, M, mm, and mmm.

1. Set the Build Environment in interactive mode. The following shows the running effect:

tapas

Step 1: select the target device:

Build for the simulator or the device?
1. Device
2. Simulator

Which would you like? [1]

Step 2: select the target code format:

Build type choices are:
1. release
2. debug

Which would you like? [1]

Step 3: select the product platform:

Product choices are:
1. emulator
2. generic
3. sim
You can also type the name of a product if you know it.
Which would you like? [generic]

Step 4: Build the platform with the selected parameters.

2. component commands of independent modules

  • M: makes from the top of the tree.
  • MM: builds all of the modules in the current directory.
  • Mmm: builds all of the modules in the supplied directories.

Among them, mmm is followed by the root directory of the module. Not all directories have sub-modules, and those directories that contain Android. mk files are
Module root directory. The module name can be obtained from the local_module or local_package_name variable of Android. mk.

To compile a module separately, specify the module path after Mmm. For example, compile contacts in application:

mmm packages/apps/Contacts/

Or run make in the src directory.Module name
:

cd ~/android/src
make Contacts

Top

Incremental compilation steps

1. modify the code

2. Compile the module where the modified Code is located, for example:

cd ~/android/src
mmm packages/apps/Contacts

3. In ~ /Android
/Src:

cd ~/android/src
make snod

This command generates a new system image system. img

4. Copy the system image to the SDK:

cd ~/android/src
cp out/target/product/generic/system.img /
out/host/linux-x86/sdk/android-sdk_eng.justin_linux-x86/tools/lib/images/

5. Delete the data left by the Program:

out/host/linux-x86/sdk/android-sdk_eng.justin_linux-x86/tools/emulator -wipe-data

 



Contact:

Mmmyddd@freeshell.org

2009 Copyleft contributed



[Top
| Up
| Dir
| Home
]


Last Updated 2009-02-13

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.