After reading the previous several books, on the Linux kernel and Android have a certain understanding, is not in the heart, want to try to build a small test the Android source code it? have been accustomed to using Windows systems, and the Android source code is not supported on Windows compilation, so decided to use the virtual machine to install Ubuntu, and then download, compile and install the Android source code.
I. Environmental preparedness.
1. Disk space reserved about 20G, memory 3G, because one side to run the host, while running virtual machines, memory requirements are relatively high, so that will be more fluent.
2. Install VMware 7.1.4. My operating system is Win7,vmware version to be new, the old version of VMware on the network support is relatively poor, because to download the Android source code on the virtual machine, no network is absolutely not.
3. After installing VMware, the Ubuntu system is installed next. I choose the latest version of ubuntu-11.04-alternate-i386, the data found on the Internet that to compile the Android source code, Ubuntu's minimum version is 8.04. When the download is good, install it with the default installation.
4. Install the Git tool. The Android source code is managed by a Git tool, which is a distributed source control tool compared to SVN, and SVN is a centralized source-control tool. To install the Git tool, execute the following commands on Ubuntu:
user-name@machine-name:~$ sudo apt-get install git-core gnupg
5. Install the Java SDK. Execute the following command on Ubuntu:
user-name@machine-name:~$ sudo add-apt-repository ppa:ferramroberto/java
user-name@machine-name:~$ sudo apt-get Update
user-name@machine-name:~$ sudo apt-get install Sun-java6-jre sun-java6-plugin
6. Other dependent packages. Execute the following command on Ubuntu:
user-name@machine-name:~$ sudo apt-get install Flex Bison gperf Libsdl-dev libesd0-dev Libwxgtk2.6-dev build-essenti Al Zip Curl
7. Debugging Tools. Execute the following command on Ubuntu:
user-name@machine-name:~$ sudo apt-get install Valgrind
Two. Download the Android source code project.
1. Download the Repo tool. Execute the following command on Ubuntu:
user-name@machine-name:~$ wget Https://dl-ssl.google.com/dl/googlesource/git-repo/repo
user-name@machine-name:~$ chmod 777 Repo
user-name@machine-name:~$ CP repo/bin/
2. Download the latest version of Android source code. Execute 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 Https://dl-ssl.google.com/dl/googlesource/git-repo/repo
user-name@machine-name:~/android $ repo Sync
after a long wait (i downloaded two or three days), I can download the Android source code. There may also be a download outage, as long as you re-execute repo sync.
Three. Compile the Android source code.
1. Compile. Under the Android directory, execute the following command:
user-name@machine-name:~/android$ Make
The first compilation to wait for a long time, after the successful compilation, 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
2. Problems that may be encountered during the compilation process.
Problem One : You are attempting into a 32-bit system.
Two places require a modification:
1) Modify the main.mk file in the build/core directory:
Ifeq ($ (build_os), Linux)
Build_arch: = $ (Shell uname-m)
#Change the following line to 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.)
2) Locate the following files:
/external/clearsilver/cgi/android.mk
/external/clearsilver/cs/android.mk
/external/clearsilver/java-jni/android.mk
/external/clearsilver/util/android.mk
To modify local_cflags and Local_ldflags variables:
# This forces a 64-bit builds for JAVA6
# change the following two lines to building on a 32-bit system.
# Local_cflags + =-m64
# Local_ldflags + =-m64
Local_cflags + +-m32
Local_ldflags + +-m32
question two : 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.cppand add the following statement:
extern "C" {
void * __dso_handle = 0;
Four. Compiling the SDK, this step is optional.
1. Compile. Execute the following command:
user-name@machine-name:~/android$ Make SDK
2. Problems that may be encountered during the compilation process.
Problem One : unable to find bios.bin and Vgabios-cirrus.bin files
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 to the Usr/share directory under the ~/android/out/host/linux-x86 directory, and the modification is to copy ~/android/prebuilt/common Pc-bios folder to /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
Issue two : Ddmlib-tests.jar, Ninepath-tests.jar, Common-tests.jar and Sdkuilib-tests.jar files are not found
In the ~/android/out/host/linux-x86/framework directory, you can find the following files Common.jar, Ddmlib.jar, Ninepatch.jar, Sdkuilib.jar these four files, and then copy them separately, and rename, naming the principle is very simple, is the original name behind the-tests can be followed.
Five. Install the compiled Android image onto 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 the ~/android/out/host/linux-x86/bin has the emulator command we're going to execute, and ~/android/out/target/product/generic is the Android mirrored storage directory, This is used when the emulator command is executed below.
2. Run the simulator.
user-name@machine-name:~/android$ Emulator
Simulator operation requires four files, respectively, Linux kernel mirror zimage and Android image files System.img, userdata.img and ramdisk.img. When the emulator command is executed, the Linux kernel mirror defaults to the Kernel-qemu file in the ~/android/prebuilt/android-arm/kernel directory, if no arguments are taken. The Android image file defaults to using the system.img, userdata.img, and ramdisk.img in the Android_product_out directory, which is the mirror problem we just compiled.
Of course, we can also run the simulator with the specified mirror file, which is when the emulator is run:
user-name@machine-name:~/android$ Emulator-kernel./prebuilt/android-arm/kernel/kernel-qemu-sysdir/out/target/ Product/generic-system System.img-data Userdata.img-ramdisk ramdisk.img
Here, we can run our own compiled Android image file on the simulator, isn't it cool? But note that the Android image file here says only includes the three files system.img, userdata.img and ramdisk.img, while Linux Kernel mirroring is the KERNEL-QEMU image that Android compiles for us. So, is there a way to use our own compiled Linux kernel mirrors? The answer is yes, so we can totally DIY our Android system! I will describe in the next article if you compile your own Linux kernel mirrors, please look forward to
PS: The latest source code on the main line is an unstable version, the use of the process may be problematic
In addition, if the source code is not downloaded from the official (everyone understands), it can be from here: Http://zhu.im/Android/
More formal source code compilation method, please refer to the official website: http://source.android.com/source/initializing.html
The above is on the Ubuntu on the Android source download, compile, installation of data collation, in this process will encounter a lot of problems, we pay attention!