1. Install JDK 6
For android2.3 systems, do not install JDK 5. Install the latest JDK 6.
If JDK 6 is installed, Android will automatically compile it in 64 bits. if the system is 32 bits, there will be a compilation error and we will talk about how to modify it later.
Sudo apt-Get install sun-java6-jdk
Sudo Update-Java-alternatives-s Java-6-sun
After installation, you must manually set java_home, jre_home, and class_path to the installation path of JDK 6.
2. install various packages
$ Sudo apt-Get install Git-core GnuPG flex bison gperf libsdl-dev libesd0-dev libwxgtk2.6-dev build-essential zip curl libncurses5-dev zlib1g-dev
3. Install Repo
$ Mkdir ~ /Bin
$ Export Path = ~ /Bin: $ path
$ Curl http://android.git.kernel.org/repo> ~ /Bin/Repo
$ Chmod A + x ~ /Bin/Repo
4. Download the android source code
$ Mkdir ~ /Android2.3
$ Cd ~ /Android2.3
$ Repo init-u git: // android.git.kernel.org/platform/manifest.git
$ Repo sync
This step lasted for a long time. The entire source code + SDK was about 5 Gb. I just downloaded it for one night, and the network speed was too low...
5. Compile Android2.3
First export ANDROID_JAVA_HOME = $ JAVA_HOME
$ Cd ~ /Android2.3
$ Source build/envsetup. sh
$ Lunch
$ Make
An error is prompted during make:
**************************************** ********************
You are attempting to build on a 32-bit system.
Only 64-bit build environments are supported beyond froyo/2.2.
**************************************** ********************
Because Android2.3 is compiled on a 64-bit system by default, You need to manually modify build/core/main. mk to comment out the judgment part:
# 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
Make again. If JDK 6 is installed, an error is returned:
Docs droiddoc: out/target/common/docs/api-stubs
Cocould not load 'clearsilver-jni'
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, because an employee of Google updates several files. Here we can see the detailed modification record: http://android.git.kernel.org /? P = platform/external/clearsilver. git; a = commitdiff; h = d201710a8110d8377b22301274d2b5425a732a72b
Modify these files and return to the 32-bit compiling environment:
External/clearsilver/cgi/Android. mk
External/clearsilver/java-jni/Android. mk
External/clearsilver/util/Android. mk
External/clearsilver/cs/Android. mk
Change the compilation option-m64 to-m32.
Re-make. make will be finished in less than an hour.