After watching the sundy video, I have some knowledge of Linux Kernel and Android. Are you ready to compile the Android source code? I am always used to using Windows, but Android source code does not support compiling on Windows. Therefore, I decided to use a virtual machine to install Ubuntu and then download, compile, and install Android source code.
1. Prepare the environment.
1. the disk space is reserved for about 20 GB and the memory is 3 GB. Because the VM is running while the host is running, the memory requirement is still relatively high, so that the disk space is smoother.
2. Install VMWare 7.1.4. My OS is Windows 7, and the VMWare version is newer. The earlier version of VMWare has poor network support. Because we need to download the Android source code from a virtual machine, no network is acceptable.
3. After VMWare is installed, install the Ubuntu system. I choose the current latest version of ubuntu-11.04-alternate-i386, from the information found on the Internet said, to compile the Android source code, the minimum version of Ubuntu is 8.04. After downloading, you can always use the default installation method during installation.
4. Install the Git tool. Android source code is managed using Git tools. Compared with SVN, SVN is a distributed source code management tool, while SVN is a centralized source code management tool. To install the Git tool, run the following command on Ubuntu:
USER-NAME @ MACHINE-NAME :~ $ Sudo apt-get install git-core gnupg
5. Install the Java SDK. Run the following command on Ubuntu:
USER-NAME @ MACHINE-NAME :~ $ Sudo add-apt-repository ppa: ferramrobert to/java
USER-NAME @ MACHINE-NAME :~ $ Sudo apt-get update
USER-NAME @ MACHINE-NAME :~ $ Sudo apt-get install sun-java6-jre sun-java6-plugin
USER-NAME @ MACHINE-NAME :~ $ Sudo apt-get install sun-java6-jdk
6. other dependent packages. Run the following command on Ubuntu:
USER-NAME @ MACHINE-NAME :~ $ Sudo apt-get install flex bison gperf libsdl-dev libesd0-dev libwxgtk2.6-dev build-essential zip curl
7. debugging tools. Run the following command on Ubuntu:
USER-NAME @ MACHINE-NAME :~ $ Sudo apt-get install valgrind
2. Download the Android source code project.
1. Download the repo tool. Run the following command on Ubuntu:
USER-NAME @ MACHINE-NAME :~ $ Wget http://android.git.kernel.org/repo
USER-NAME @ MACHINE-NAME :~ $ Chmod 777 repo
USER-NAME @ MACHINE-NAME :~ $ Cp repo/bin/
2. Download the source code of the latest Android version. Run the following command on Ubuntu:
USER-NAME @ MACHINE-NAME :~ $ Mkdir Android
USER-NAME @ MACHINE-NAME :~ $ Cd Android
USER-NAME @ MACHINE-NAME :~ /Android $ repo init-u git: // android.git.kernel.org/platform/manifest.git
USER-NAME @ MACHINE-NAME :~ /Android $ repo sync
After a long wait (I downloaded it for two or three days), I can download the Android source code. In this case, the download may be interrupted. You only need to re-Execute repo sync.
3. Compile the Android source code.
1. compile. Run the following command in the Android directory:
USER-NAME @ MACHINE-NAME :~ /Android $ make
The first compilation takes a long time. After the compilation is successful, you can see the following output:
Target system fs image: out/target/product/generic/obj/PACKAGING/systemimage_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
Installed file list: out/target/product/generic/installed-files.txt
2. problems that may occur during compilation.
Question 1: You are attempting to build on a 32-bit system.
Two changes are required:
1) modify the main. mk file in the build/core directory:
Ifeq ($ (BUILD_ OS), linux)
Build_arch: = $ (shell uname-m)
# Change the following line for building on a 32-bit system.
# Ifneq (64, $ (findstring 64, $ (build_arch )))
Ifneq (i686, $ (findstring i686, $ (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 .)
2) Find the following files:
/External/clearsilver/cgi/Android. mk
/External/clearsilver/cs/Android. mk
/External/clearsilver/java-jni/Android. mk
/External/clearsilver/util/Android. mk
Modify the variables LOCAL_CFLAGS and LOCAL_LDFLAGS:
# This forces a 64-bit build for Java6
# Change the following two lines for building on a 32-bit system.
# LOCAL_CFLAGS + =-m64
# LOCAL_LDFLAGS + =-m64
LOCAL_CFLAGS + =-m32
LOCAL_LDFLAGS + =-m32
Question 2: Undefined reference to '_ dso_handle'
External/stlport/src/monetary. cpp: 39: undefined reference to '_ dso_handle'
Out/target/product/vm/obj/SHARED_LIBRARIES/libstlport_intermediates/src/locale. o: In function '_ static_initialization_and_destruction_0 ':
External/stlport/src/locale. cpp: 29: undefined reference to '_ dso_handle'
Out/target/product/vm/obj/SHARED_LIBRARIES/libstlport_intermediates/src/locale_impl.o: In function '_ static_initialization_and_destruction_0 ':
External/stlport/src/locale_impl.cpp: 31: undefined reference to '_ dso_handle'
Out/target/product/vm/obj/SHARED_LIBRARIES/libstlport_intermediates/src/locale_impl.o: In function 'std: _ Locale_impl: make_classic_locale ()':
External/stlport/src/locale_impl.cpp: 670: undefined reference to '_ dso_handle'
External/stlport/src/locale_impl.cpp: 667: undefined reference to '_ dso_handle'
Out/target/product/vm/obj/SHARED_LIBRARIES/libstlport_intermediates/src/locale_impl.o: external/stlport/src/locale_impl.cpp: 604: more undefined
References to '_ dso_handle' follow
Collect2: ld returned 1 exit status
Modify external/stlport/dll_main.cpp and add the following statement:
Extern "C "{
Void * _ dso_handle = 0;
}
4. Compile the SDK. This step is optional.
1. compile. Run the following command:
USER-NAME @ MACHINE-NAME :~ /Android $ make sdk
2. problems that may occur during compilation.
Problem 1: unable to find bios. bin and vgabios-cirrus.bin File
Couldn't locate source file: usr/share/pc-bios/bios. bin
Couldn't locate source file: usr/share/pc-bios/vgabios-cirrus.bin
Note that the usr/share directory here refers ~ /Android/out/host/usr/share directory under the linux-x86 directory, the modification is to copy ~ /Android/prebuilt/common pc-bios folder ~ /Android/out/host/linux-x86/usr/share can be:
USER-NAME @ MACHINE-NAME :~ /Android $ cp ~ /Android/prebuilt/common/pc-bios ~ /Android/out/host/linux-x86/usr/share
Problem 2: ddmlib-tests.jar, ninepath-tests.jar, common-tests.jar, and sdkuilib-tests.jar files not found
In ~ /Android/out/host/linux-x86/framework directory, you can find the following files common. jar, ddmlib. jar, ninepatch. jar, sdkuilib. jar files, copy them separately, and rename them. The naming principle is very simple, that is, keep up with-tests after the original name.
5. Install the compiled Android image on the simulator.
1. Set environment variables:
USER-NAME @ MACHINE-NAME :~ /Android $ export PATH = $ PATH :~ /Android/out/host/linux-x86/bin
USER-NAME @ MACHINE-NAME :~ /Android $ export ANDROID_PRODUCT_OUT = ~ /Android/out/target/product/generic
Where ,~ /Android/out/host/linux-x86/bin has the emulator command we want to execute, and ~ /Android/out/target/product/generic is the directory for storing Android images. It will be used when the emulator command is executed below.
2. Run the simulator.
USER-NAME @ MACHINE-NAME :~ /Android $ emulator
Four files are required to run the simulator: Linux Kernel image zImage and Android Image File system. img, userdata. img, and ramdisk. img. If the emulator command is executed without any parameters, the Linux Kernel image is used by default ~ The kernel-qemu file in the/Android/prebuilt/android-arm/kernel directory, while the Android image file uses the system in the ANDROID_PRODUCT_OUT directory by default. img, userdata. img and ramdisk. img, that is, the image we just compiled.
Of course, we can also run the simulator with the specified image file, that is, when running emulator, that is:
USER-NAME @ MACHINE-NAME :~ /Android $ emulator-kernel. /prebuilt/android-arm/kernel-qemu-sysdir. /out/target/product/generic-system. img-data userdata. img-ramdisk. img
Now, we can run our own Android image file on the simulator. Is it cool? However, note that the Android image file here only includes system. img, userdata. img and ramdisk. the Linux Kernel image uses the pre-compiled kernel-qemu image of Android. Is there a way to use our own compiled Linux Kernel image? The answer is yes, so that we can completely DIY our Android system! In the next article, I will describe how to compile your Linux Kernel image ~