Android source code Building compiled source environment (Ubuntu article)

Source: Internet
Author: User
Tags gnupg

The source code has been tested by the official on Ubuntu LTS (14.04). Other systems are also available, and the author recommends using Ubuntu LTS (14.04).

First, the system requirements:

1. Linux or Mac (also available under Linux on virtual machines)

2, to compile gingerbread (2.3.x) and the above version of the source code, requires 64-bit system environment, gingerbread (2.3.x) Previous version can be compiled on 32-bit systems.

Source code version name and version number, API level list see: http://blog.csdn.net/u013647453/article/details/45512455

3. At least 50GB is used to download the source code (a checkout), a single-branch compilation (one build) requires 100GB, multi-branch compilation (multiple build) requires more than or equal to 150GB of space.

4.python2.6-2.7, official website: python.org (Ubuntu built-in, command line: Python can view version)

5.GNU make3.81--3.82, official website: gnu.org (Ubuntu built-in, command line: Make-version view version)

6. Compiling the master branch requires JDK7, compiling the gingerbread to KitKat version requires JDK6, and compiling cupcake to Froyo version requires JDK5.

Installation JDK7: $sudo apt-get Update

$sudo apt-get Install openjdk-7-jdk (command line: Java-version View current version)

7.git1.7 and above, official website: git-scm.com (Ubuntu is not built-in, use sudo apt-get install git for installation, Git--version view version after installation)


Second, install the necessary packages

For Ubuntu 14.04:

$ sudo apt-get install bison g++-multilib git gperf libxml2-utils make zlib1g-dev:i386 zip


For Ubuntu 12.04:

$ sudo apt-get install git gnupg flex bison gperf build-essential \
Zip curl Libc6-dev libncurses5-dev:i386 x11proto-core-dev \
libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-glx:i386 \
Libgl1-mesa-dev g++-multilib mingw32 tofrodos \
Python-markdown libxml2-utils Xsltproc zlib1g-dev:i386
$ sudo ln-s/usr/lib/i386-linux-gnu/mesa/libgl.so.1/usr/lib/i386-linux-gnu/libgl.so


For Ubuntu 10.4-11.10:

$ sudo apt-get install git 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

Also for 10.10 to execute: sudo ln-s/usr/lib32/mesa/libgl.so.1/usr/lib32/mesa/libgl.so

For 11.10 also perform: $ sudo apt-get install libx11-dev:i386


Third, supplementary

1. Use CCache.

CCache means a compile-time cache (Compiler cache) that can be used to speed up recompilation (rebuild). It is recommended to use CCache if you frequently use the make clean command, or if you often want to toggle between compiled things.

Add a downstream statement to the. bashrc file (~ directory). The cached files are stored by default in the ~/.ccache folder.

Export use_ccache=1

The recommended cache size is set to 50-100GB. Ubuntu Settings command: (need to download good source code after use)

Prebuilts/misc/linux-x86/ccache/ccache-m 50G

On an Apple computer, the command is: (change linux-x86 to Darwin-x86)

Prebuilts/misc/darwin-x86/ccache/ccache-m 50G

If the source code that needs to be compiled is Ice Cream Sandwich (4.0.x) and previous versions, the command is:

Prebuilt/linux-x86/ccache/ccache-m 50G

The execution result of the above command is permanently stored in the Ccache_dir.


2. Change the compiled output folder location (only jelly beans (4.1) and above are supported)

By default, the compiled output file is stored in the out directory under the source code folder.

If your computer has multiple partitions, you can speed up the compilation by placing the output folder in the same partition as the non-source code. If you want to compile faster, choose a partition that stores faster formats, not a higher-security format.

Setup method:

Export out_dir_common_base=<path-to-your-out-directory>


3. System plug-in USB device unresponsive problem Resolution: (For older system versions, newer versions of the system without this problem, this method has been tested on Ubuntu 8.04.x lts and 10.04.x lts valid, other versions cannot be guaranteed)


New file: /etc/udev/rules.d/51-android.rules (root user)

Paste the following and reseat the device: (where <username> to be replaced by the user to read the USB)

# 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>"
# ADB protocol on Panda (PandaBoard ES)
subsystem== "USB", attr{idvendor}== "18d1", attr{idproduct}== "d002", 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}== "d00f", mode= "0600", owner= "<username>"
# Usbboot protocol on Panda (PandaBoard ES)
subsystem== "USB", attr{idvendor}== "0451", attr{idproduct}== "d010", mode= "0600", owner= "<username>"
# ADB protocol on Grouper/tilapia (Nexus 7)
subsystem== "USB", attr{idvendor}== "18d1", attr{idproduct}== "4e42", mode= "0600", owner= "<username>"
# FastBoot protocol on Grouper/tilapia (Nexus 7)
subsystem== "USB", attr{idvendor}== "18d1", attr{idproduct}== "4e40", mode= "0600", owner= "<username>"
# ADB protocol on Manta (Nexus 10)
subsystem== "USB", attr{idvendor}== "18d1", attr{idproduct}== "4ee2", mode= "0600", owner= "<username>"
# FastBoot protocol on Manta (Nexus 10)
subsystem== "USB", attr{idvendor}== "18d1", attr{idproduct}== "4ee0", mode= "0600", owner= "<username>"


If the above content is false, please point out, thank you!

Android source code Building compiled source environment (Ubuntu 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.