There are many such tutorials on the web, just record it for future viewing.
Official website Tutorial:http://source.android.com/source/building.html
Download source code
It is divided into the following steps:
1. Configure and install the download environment
Configuring the JDK Environment
Installing Curl, Git-core software
sudo apt-get Install Curl
sudo apt-get install Git-core
2. Create a ~/bin directory and add it to the environment variable
mkdir ~/bin
Path=~/bin: $PATH
3. Download repo script and modify permissions to execute
Curl Https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo (this is likely to download timeout)
Curl "Http://php.webtutor.pl/en/wp-content/uploads/2011/09/repo" > ~/bin/repo (Download failure above can download this)
chmod A+x~/bin/repo
4, create a directory to save Android source code, modify the maximum permissions, and enter into the directory
Mkdir/opt/android_source
sudo chmod–r 777/opt/android_source
Cd/opt/android_source
5. Initialize the repo and select the branch (version) to download
Repo Init-u Https://android.googlesource.com/platform/manifest (This is the latest source)
Repo Init-u https://android.googlesource.com/platform/manifest-b Android-4.2_r1 (This is the Android4.2 system source code, the other version as long as the branch number can be replaced)
6, prompt to enter your name, email.
7, start to download the source code
Repo Sync
Frequently encountered error conditions:
Scenario 1:
error:failed onnect o android.googlesource.com:443;
Connection efused while accessing
Https://android.googlesource.com/a/platform/frameworks/base/info/refs
Fatal:http request failed
Error:cannot Fetch Platform/tools/motodev
Error:cannot Fetch Platform/frameworks/base
Error:cannot Fetch PLATFORM/PREBUILTS/SDK
error:exited sync due to fetch errors
Solve:
Edit/etc/hosts File
Vim/etc/hosts
Add the following content to save
74.125.31.82 www.googlesource.com
74.125.31.82 android.googlesource.com
203.208.46.172 cache.pack.google.com
59.24.3.173 cache.pack.google.com
Compiling source code
1. Download the required software
sudo apt-Getinstall 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
2. Create a link
Sudo ln-s/usr/Lib/i386-Linux-GNU/Mesa/Libgl. So.1 /usr/Lib/i386-Linux-GNU/Libgl. So
3. Configure GCC
sudo apt-get install gcc-4.4
sudo apt-get install g++-4.4
4. Compiling the source code
Cd/opt/android_source
source build/envsetup.sh or. b uild/envsetup.sh
Lunch Full - Eng
Make - J4
5. Start the simulator
Emulator