"Go" download, compile and install the latest Android source code on Ubuntu

Source: Internet
Author: User
Tags using git

Original URL: http://blog.csdn.net/luoshengyang/article/details/6559955

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 a Android source code it? has been accustomed to using Windows systems, and Android source code is not supported on the compilation on Windows, so decided to use the virtual machine to install 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 relatively high, so that it will be more fluent.

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

3. After installing VMware, the Ubuntu system is installed next. I choose the latest version of Ubuntu-11.04-alternate-i386, the data from the Internet said that to compile Android source code, the minimum version of Ubuntu is 8.04. Once downloaded, the installation is always installed by default.

4. Install the Git tool. Android source code is managed using Git tools, 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 command on Ubuntu:

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

5. Install the Java SDK. Execute 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 it. Execute the following command on Ubuntu: [email protected]:~$ sudo apt-get install Flex Bison gperf libsdl-dev libesd0-dev libwxgtk2.6-dev build-essential zip Curl7. Debugging Tools. Execute the following command on Ubuntu: [email protected]:~$ sudo apt-get install Valgrind   two. Download the Android source code project. 1. Download the Repo tool. Execute the following command on Ubuntu: [Email protected]:~$ wget https://dl-ssl.google.com/dl/googlesource/git-repo/repo [email protecte d]:~$ chmod 777 Repo [email protected]:~$ cp REPO/BIN/2. Download the latest version of Android source code. Execute the following command on Ubuntu:

[email protected]:~$ mkdir Android

[email protected]:~$ cd Android [email protected]:~/android$ repo init-uHttps://dl-ssl.google.com/dl/googlesource/git-repo/repo [email protected]:~/android$ repo Sync      After a long wait (i downloaded it for two or three days), I can download the Android source code.     There may also be a situation where you experience a download outage, as long as you re-execute repo sync.     Three. Compile the Android source code. 1. Compile. In the Android directory, execute the following command: [email protected]:~/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 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) 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 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 modifying 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       Modify External/stlport/dll_ Main.cpp, add the following statement:     extern "C" { void * __dso_handle = 0;      }  four. Compile the SDK, this step is optional. 1. Compile. Execute 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 directory here refers to the Usr/share directory under the ~/android/out/host/linux-x86 directory, which is modified by copying ~/android/prebuilt/ Common the Pc-bios folder to ~/android/out/host/linux-x86/usr/share: [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 In ~/android/out/host/linux-x86/framework this directory, you 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 simple, that is, after the original name with-tests.    Five. Install the compiled Android image onto the emulator. 1. Set Environment variables: [email protected]:~/android$ export path= $PATH: ~/android/out/host/linux-x86/bin [email protected]:~/android$ export Android_product_out=~/android/out/target/product/generic     Among them, ~/android/out/host/linux-x86/bin has the emulator command we want to execute, and ~/android/out/target/product/generic is the Android image storage directory,    This is used when executing the emulator command below. 2. Run the emulator. [email protected]:~/android$ emulator     The emulator operation requires four files, namely the Linux kernel Mirror Zimage and the Android image file System.img, userdata.img, and ramdisk.img. When you execute the emulator command, if you do not have any parameters, the Linux kernel image defaults to the Kernel-qemu file in the ~/android/prebuilt/android-arm/kernel directory.    The Android image file uses the system.img, userdata.img, and ramdisk.img in the Android_product_out directory by default, which is the image 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 can run our own compiled Android image file on the emulator, isn't it cool? But note that the Android image file mentioned here is just three files including 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 yes, so we can completely DIY our own Android system! I will describe in the next article if you compile your own Linux kernel image, so please wait ~

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

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

More formal method of compiling source code, please refer to the official website: http://source.android.com/source/initializing.html

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

"Go" download, compile and install the latest Android source code on Ubuntu

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.