Download, compile and install the latest Android source code on Ubuntu

Source: Internet
Author: User

After reading the previous said a few books, to Linux kernel and Android have a certain understanding, is not in the mind, want to try to sledgehammer himself compiled an android source? has been accustomed to the use of Windows systems, and Android source code is not supported on the compilation on Windows, so decided to use the virtual machine installed Ubuntu, and then download, compile and install Android source code.

I. Environmental preparedness.

1. Disk space reserved about 20G, memory 3G, because one side to run the host, side to run the virtual machine, memory requirements or higher, so that will be more fluent.

2. Install VMware 7.1.4. My operating system is Win7,vmware version number to a new point, the old version number of VMware in the network support is worse, because to download Android source on the virtual machine, no network is absolutely no.

3. After installing VMware, the Ubuntu system is installed next. I choose the latest version number ubuntu-11.04-alternate-i386, from the online information found that to compile Android source code, Ubuntu minimum version number is 8.04. Once downloaded, the installation will be installed by default.

4. Install the Git tool. Android source with Git tools to manage, compared to SVN, this is a distributed source management tools, and SVN is a centralized source management tools. To install the Git tool, run the following command on Ubuntu to:

[email protected]:~$ sudo apt-get install git-core gnupg

5. Install the Java SDK. Run the following command on Ubuntu:

[Email protected]:~$ sudo add-apt-repository Ppa:ferramroberto/java [Email protected]:~$ sudo apt-get update [Email protected]:~$ sudo apt-get install Sun-java6-jre sun-java6-plugin [Email protected]:~$ sudo apt-get install SUN-JAVA6-JDK     6. Other packages that depend on. Run the following command on Ubuntu:
[email protected]:~$ 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:
[email protected]:~$ sudo apt-get install valgrind
two. Download Android source project.
1. Download the Repo tool. Run the following command on Ubuntu:
     [Email protected]:~$ wget Https://dl-ssl.google.com/dl/googlesource/git-repo/repo[Email protected]:~$ chmod 777 Repo [email protected]:~$ cp repo/bin/     2. Download the latest Android version code. Run the following command on Ubuntu:

[email protected]:~$ mkdir Android

[email protected]:~$ cd Android [email protected]:~/android$ repo init-u Https://dl-ssl.google.com/dl/googlesource/git-repo/repo [email protected]:~/android$ repo Sync      After a long wait (i downloaded two or three days), I was able to download the Android source.     While there may be a download outage, it is only possible to run repo sync again.     Three. Compile Android source code. 1. Compile. Under the Android folder, run the following command: [email protected]:~/android$ Make      The first compilation to wait for a longer 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 installed file List:out/target/product/generic/installed-files.txt      2. Issues that you may encounter during the compilation process. problem One: You were attempting to build on a 32-bit system.Two places need a change: 1) Change the main.mk file under the Build/core folder: 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 is attempting to build on a 32-bit system.) $ (Warning only 64-bit build environments is supported beyond froyo/2.2.)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 change local_cflags and Local_ldflags variables: # This forces a 64-bit build for Java6 # Change the following and lines for 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       change External/stlport/dll_main.cpp, Tim? The following statement:     extern "C" { void * __dso_handle = 0;      }  Four. Compile the SDK, this step is optional. 1. Compile. Run the following command: [Email protected]:~/android$ make SDK      2. Issues that you may encounter during the compilation process. problem One: The Bios.bin and Vgabios-cirrus.bin files are not foundCouldn ' 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 folder here refers to the ~/android/out/host/linux-x86 folder under the Usr/share folder, the change is to copy ~/android/prebuilt/ Common the Pc-bios folder to ~/android/out/host/linux-x86/usr/share, you can: [email protected]:~/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 Under ~/android/out/host/linux-x86/framework This folder, can find the following several files Common.jar, Ddmlib.jar, Ninepatch.jar,    Sdkuilib.jar these four files, and then copy them separately, and rename them, the principle of naming is very easy, that is, after the original name to keep up with-tests.    Five. Install the compiled Android image onto the emulator. 1. Environment variable settings: [email protected]:~/android$ export path= $PATH: ~/android/out/host/linux-x86/bin [email protected]:~/android$ export Android_product_out=~/android/out/target/product/generic     Of~/android/out/host/linux-x86/bin has the emulator command we want to run, and~/android/out/target/product/generic is an Android image storage folder, which is used when running the emulator command. 2. Run the emulator.      [email protected]:~/android$ emulator     The simulator requires four files, each of which is a Linux kernel mirror zimage and Android image file System.img, userdata.img, and ramdisk.img. When running the emulator command, assume that the Linux kernel image uses the Kernel-qemu file under the ~/android/prebuilt/android-arm/kernel folder by default, without any parameters, And the Android image file is used by defaultunder the Android_product_out folderSystem.img, Userdata.img, and ramdisk.img, the mirror problem we just compiled. Of course, we can also run the emulator with the specified image file, that is, when running emulator, that is: [Email protected]:~/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 are able to run our own compiled Android image file on the emulator, isn't it really cool? Note, however, that the Android image file mentioned here is only three files that contain system.img, userdata.img, and Ramdisk.img, while the Linux The kernel image is used by Android to pre-compile the Kernel-qemu image for us. So, is there a way to use our own compiled Linux kernel image? The answer is sure, so that we can completely DIY their Android system! I'm going to write my own Linux kernel image in the next article on the narrative hypothesis, so please wait


PS: The latest source code on the main line is an unstable version number, the use of the process may be problematic

In addition, if the official download from the source (you understand), can be from here: Http://zhu.im/Android/

More formal source code compiling method, please refer to the Examiner Net: http://source.android.com/source/initializing.html

Lao Luo's Sina Weibo: Http://weibo.com/shengyangluo, welcome attention!

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.