A few days ago, I downloaded the source code of Android 2.3.1 and compiled it on Ubuntu 10.04 (32-bit. This article briefly records the download and compilation processes.
There are many articles about how to build an android development environment. This article will only briefly introduce them as a memo.
[Preparations before compilation]
Run the following command to install and obtain the source code and compile the required software:
$ Sudo aptitude install Git-core GnuPG flex bison gperf libsdl-dev libesd0-dev libwxgtk2.6-dev build-essential zip curl libncurses5-dev zlib1g-dev. In addition, the following software packages are installed based on others' experience in compiling Android 2.3:
$ Sudo apt-Get install lib64z1-dev libc6-dev-amd64 g ++-multilib lib64stdc ++ 6 Although Android official website does not support Java 6, but I use Java 6 can also be compiled through, so here easwy installs Java 6. First, remove the comments of the two lines in/etc/APT/sources. List to enable Java 6 Source:
Deb http://archive.canonical.com/ubuntu lucid partner
Deb-Src http://archive.canonical.com/ubuntu lucid partner and then install Java 6 JDK:
$ Sudo aptitude install sun-java6-jdk next download repo tool, which is a Python script provided by Google for managing multiple git Repository:
$ Cd ~
$ Mkdir Bin
$ Curl http://android.git.kernel.org/repo> ~ /Bin/Repo
$ Chmod A + x ~ /Bin/repo remember to add the repo to your path for future use. Edit ~ /. Bashrc, add the following line:
Path = $ path :~ /Bin
Use the export path command .~ /. Bashrc. You can directly use the repo command later.
Next, obtain the source code of Android 2.3.1:
$ Mkdir mydroid
$ CD mydroid
$ Repo init-u git: // android.git.kernel.org/platform/manifest.git-B android-2.3.1_r1
$ Repo sync [compile Android]
Next, compile:
$ Make-J 'grep' ^ processor '/proc/cpuinfo | WC-l' in the preceding command, the-J parameter tells make to start multiple parallel tasks for compilation, it can speed up compilation on CPU supporting multiple cores. If you know how many cores your CPU is, you can directly replace this part with-J2 (dual-core ).
During compilation, I encountered the following error:
**************************************** ********************
You are attempting to build on a 32-bit system.
Only 64-bit build environments are supported beyond froyo/2.2.
**************************************** ********************
This is because the CPU length is detected in makefile. I will comment out the following in build/CORE/Main. mk:
# Ifneq (64, $ (findstring 64, $ (build_arch )))
# $ (Warning ************************************ ************************)
# $ (Warning you are attempting to build on a 32-bit system .)
# $ (Warning only 64-bit build environments are supported beyond froyo/2.2 .)
# $ (Warning ************************************ ************************)
# $ (Error stop)
# Endif:
Docs droiddoc: Out/target/common/docs/API-stubs
Cocould not load 'clearsilver-JNI'
Www.2cto.com
Java. Library. Path = out/host/ linux-x86/lib
Make: *** [out/target/common/docs/API-stubs-timestamp] Error 45
Make: *** waiting for unfinished jobs ....
Cocould not load 'clearsilver-JNI'
Java. Library. Path = out/host/ linux-x86/lib
Make: *** [out/target/common/docs/doc-comment-check-timestamp] Error 45
This is because clearsilver uses 64-bit compilation if it detects that Java JDK 6 is used during compilation. To avoid this error, You need to modify the following four files:
External/clearsilver/cgi/Android. mk
External/clearsilver/Java-JNI/Android. mk
External/clearsilver/util/Android. mk
External/clearsilver/CS/Android. mk
Note the following statements in the four makefiles:
# This forces a 64-bit build for java6
# Comment by easwy
# Local_cflags + =-M64
# Local_ldflags + =-M64, execute make clean in the external/clearsilver directory, return to the project root directory, and continue to make.
When compilation is complete, the generated image file is placed in the out/target/product/Generic Directory.