By referring to relevant information on the Internet, follow these steps to compile the android source code:
- 1. My system is Ubuntu 8.04.
- 2. The following tools must be installed on the system (from documents on the Internet ):
Sudo apt-Get install build-essential
Sudo apt-Get install make
Sudo apt-Get install gcc
Sudo apt-Get install g ++
Sudo apt-Get install libc6-dev
Sudo apt-Get install flex
Sudo apt-Get install bison
Sudo apt-Get Install patch
Sudo apt-Get install texinfo
Sudo apt-Get install libncurses-Dev
Sudo apt-Get install Git-core GnuPG // (the GnuPG system may already come with it)
Sudo apt-Get install flex bison gperf libsdl-dev libesd0-dev libwxgtk2.6-dev build-essential zip curl
Sudo apt-Get install ncurses-Dev
Sudo apt-Get install zlib1g-dev
Sudo apt-Get install valgrind (optional, 21 MB in size, I don't think most people can use it)
Sudo apt-Get install python2.5 (you don't need to install it. Ubuntu 8.04 already comes with it)
Sudo apt-Get install sun-java5-jdk
Note:
A. Do not use sun-java6-jdk, or in make SDK, specifically make Doc this step, encountered this error:
Docs droiddoc: Out/target/common/docs/dx
Javadoc: Error-In doclet class droiddoc, method start has thrown
Exception java. Lang. Reflect. invocationtargetexception
Com. Sun. Tools. javac. Code. symbol $ completionfailure: class file
Sun. util. Resources. openlistresourcebundle not found
B. According to the online documents, you need to set environment variables, but I have not set them:
Export android_java_home = $ java_home
C. ncurses-dev installation is not mentioned on the Internet, but compilation errors may occur during the compilation process before installation.
- 3. Create a directory for storing the android source code
$ Mkdir ~ /Open_src
$ Mkdir ~ /Open_src/android
$ Cd ~ /Open_src/android
$ Mkdir bi
- 4. Download the repo script and place it in ~ /Open_src/Android/bin directory with executable permission
$ Curl http://android.git.kernel.org/repo> Repo
$ Sudo MV repo ~ /Open_src/Android/bin
$ Sudo chmod A + x ~ /Open_src/Android/bin/Repo
- 5. Run the following command in the source code storage directory Android:
$ ~ /Open_src/Android/bin/repo init-u git: // android.git.kernel.org/platform/manifest.git
// An email or something will be prompted in the middle. If you are planning to submit a patch, use the email address registered by Google accounts.
- 6. Run repo sync in the android directory to download the source code.
We can also copy the source code from other places to the android directory, which is exactly what I did.
- 7. Compile the source code and get ~ /Open_src/Android/out directory
Run the make command on the command line:
$ Make
This is a long process. Wait ......
- 8. Test Run
8.1 set the environment variable first:
Open ~ /. Bashrc file, and add the following two lines at the end:
Export Path = $ path :~ /Open_src/Android/out/host/linux-x86/bin
Export android_product_out = ~ /Open_src/Android/out/target/product/generic
8.2 running simulator:
Emulator -- debug-init-skin QVGA-L // may prompt unknown option: -- debug-init, remove -- debug-init
Or execute emulator directly to use the default skin.
If you can finally access the system and see a big clock, it means you're done.
- 9 subsequent compilation:
Run
$. Build/envsetup. Sh
Then you will have several more available commands. After changing the contacts Contact project, you can simply execute the command to compile this part separately:
$ Mmm packages/apps/contacts/
To directly test the changes, you need to generate a new system. IMG and run the following command in the android directory:
$ Make Snod
Of course, if you change emulator or other peripheral-related things, instead of internal system things, you don't just need to regenerate system. IMG.
- The following are the final outputs after compilation:
Install: Out/target/product/generic/system/xbin/SCP
Notice file: System/extras/showmap/notice -- out/target/product/generic/obj/notice_files/src // system/xbin/showmap.txt
Install: Out/target/product/generic/system/xbin/showmap
Notice file: System/extras/showslab/notice -- out/target/product/generic/obj/notice_files/src // system/xbin/showslab.txt
Install: Out/target/product/generic/system/xbin/showslab
Notice file: external/SQLite/Dist/notice -- out/target/product/generic/obj/notice_files/src // system/xbin/sqlite3.txt
Install: Out/target/product/generic/system/xbin/sqlite3
Notice file: external/dropbear/notice -- out/target/product/generic/obj/notice_files/src // system/xbin/ssh.txt
Install: Out/target/product/generic/system/xbin/ssh
Install: Out/target/product/generic/system/xbin/strace
Notice file: System/extras/SU/notice -- out/target/product/generic/obj/notice_files/src // system/xbin/su.txt
Install: Out/target/product/generic/system/xbin/su
Install: Out/target/product/generic/system/xbin/timeinfo
Copy: Out/target/product/generic/system/etc/apns-conf.xml
Copying: Out/target/product/generic/obj/notice_files/src/kernel.txt
Finding notice files: Out/target/product/generic/obj/notice_files/hash-Timestamp
Combining notice files: Out/target/product/generic/obj/notice.html
Gzip-C out/target/product/generic/obj/notice.html> out/target/product/generic/obj/notice.html.gz
Zip-Qj out/target/product/generic/system/etc/security/otacerts.zip build/target/product/security/testkey. x509.pem
Generated: (Out/target/product/generic/android-info.txt)
Target System FS image: Out/target/product/generic/obj/packaging/systemimage_unopt_intermediates/system. img
Install system FS image: Out/target/product/generic/system. img
Target RAM disk: Out/target/product/generic/ramdisk. img
Target userdata FS image: Out/target/product/generic/userdata. img
- Jo @ sliao :~ $