Luo niuwen 2. Download, compile, and install the latest Android source code on Ubuntu

Source: Internet
Author: User
Tags using git

After reading the previous books, I have a certain understanding of Linux kernel and Android. Do you want to compile your own 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 packages dependent on. 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.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' _ handle ': 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 FileCouldn't locate source file: usr/share/PC-bios/BIOS. bin couldn't locate source file: usr/share/PC-bios/vgabios-cirrus.bin note, here the usr/share directory 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 foundIn ~ /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 own Linux
Kernel image, coming soon ~

Address: http://blog.csdn.net/luoshengyang/article/details/6559955

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.