Download and compile Android source code

Source: Internet
Author: User

(Google http://source.android.com/source)

Build a compilation environment

1. Initial language compilation environment

The source code size is about 6 GB. It takes about 25 GB to complete a compilation, and my hard drive is 50 GB.

2. Create a Linux Image

Google Doc (http://source.android.com/source/) recommends Ubuntu 10.10 64-bit (LTs), which is my system version. The following software is generally needed:

Python 2.5 -- 2.7, which you can download from
Python.org.

GNU make 3.81 -- 3.82, which you can download from
Gnu.org,

JDK 6 if you wish to build gingerbread or newer; JDK 5 for froyo or older. You can download both fromjava.sun.com. (gingerbread, froyo is an identifier of the android source code)

Git 1.7 or newer. You can find it at git-scm.com.

3. install Java SDK

$ sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner"

$ sudo apt-get update

$ sudo apt-get install sun-java6-jdk

There will be an error where the sun-java6-jdk cannot be found.
Java.sun.com downloaded the jdk-6u31-linux-x64.bin file and installed. Be sure to configure the environment variables, Google doc did not say this.

4. Install the required package

$ sudo apt-get install git-core gnupg flex bison gperf build-essential \  zip curl zlib1g-dev libc6-dev lib32ncurses5-dev ia32-libs \  x11proto-core-dev libx11-dev lib32readline5-dev lib32z-dev \  libgl1-mesa-dev g++-multilib mingw32 tofrodos python-markdown \  libxml2-utils xsltproc

5. Configure USB access

Open/etc/udev/rules.d/51-android.rulesFile (Root), add the following content, replace username with your secret name

# adb protocol on passion (Nexus One)SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e12", MODE="0600", OWNER="<username>"# fastboot protocol on passion (Nexus One)SUBSYSTEM=="usb", ATTR{idVendor}=="0bb4", ATTR{idProduct}=="0fff", MODE="0600", OWNER="<username>"# adb protocol on crespo/crespo4g (Nexus S)SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e22", MODE="0600", OWNER="<username>"# fastboot protocol on crespo/crespo4g (Nexus S)SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e20", MODE="0600", OWNER="<username>"# adb protocol on stingray/wingray (Xoom)SUBSYSTEM=="usb", ATTR{idVendor}=="22b8", ATTR{idProduct}=="70a9", MODE="0600", OWNER="<username>"# fastboot protocol on stingray/wingray (Xoom)SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="708c", MODE="0600", OWNER="<username>"# adb protocol on maguro/toro (Galaxy Nexus)SUBSYSTEM=="usb", ATTR{idVendor}=="04e8", ATTR{idProduct}=="6860", MODE="0600", OWNER="<username>"# fastboot protocol on maguro/toro (Galaxy Nexus)SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e30", MODE="0600", OWNER="<username>"# adb protocol on panda (PandaBoard)SUBSYSTEM=="usb", ATTR{idVendor}=="0451", ATTR{idProduct}=="d101", MODE="0600", OWNER="<username>"# fastboot protocol on panda (PandaBoard)SUBSYSTEM=="usb", ATTR{idVendor}=="0451", ATTR{idProduct}=="d022", MODE="0600", OWNER="<username>"# usbboot protocol on panda (PandaBoard)SUBSYSTEM=="usb", ATTR{idVendor}=="0451", ATTR{idProduct}=="d010", MODE="0600", OWNER="<username>"

6. Establish ccache (to speed up compilation)

Add the following content to. bashrc

export USE_CCACHE=1

Export ccache_dir = <~ /. Ccache>(This sentence does not understand the meaning of the document, so it is written in this way)

Ii. Download source code

1. Install Repo

(Make sure that the home directory contains the bin directory and is in the path)

$ Mkdir ~ /Bin

$ Path = ~ /Bin: $ path

(Download the repo script file and make sure it is executable)

$ curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo$ chmod a+x ~/bin/repo

2. initialize the repo Client

(Source is the place where the source file is placed)

$ mkdir source$ cd source
Download the latest repo version (use git branch-R command to view all versions) $ repo init-u https://android.googlesource.com/platform/manifest

Download the specified version.android-4.0.1_r1):

$ repo init -u https://android.googlesource.com/platform/manifest -b android-4.0.1_r1

Start download. During the download process, enter the name and email address. If the download is interrupted, run the following command to continue the download.

$ repo sync

Run the following command after the source code is downloaded to set the size of the slow charge zone.

prebuilt/linux-x86/ccache/ccache -M 50G

3. Compile the system

Initialize the compiling environment

$ source build/envsetup.sh

Select a target

$ lunch full-eng

Compile

$ Make-J4

Start the simulator

$ emulator

The effect is as follows:


Wow, it's better ~~

Compile a package:

make ONE_SHOT_MAKEFILE=packages/apps/Launcher2/Android.mk


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.