Compiling Android source code and kernel summary

Source: Internet
Author: User

These smallpox for some time to download the Android source code to compile, which took a few detours lead to a bit of time, and now another carding summary, so that the same idea of the people to compile their own time can be less detours, official guidance documents in http://source.android.com/ Source/initializing.html.

1. Install Linux Environment

I am a Windows system with a VMware virtual machine installed. ubuntu-12.04 on the virtual machine, my version number is 32 bits , this is quite important. Installing 32-bit or 64-bit will determine the Android version number you can compile, the official document for Gingerbread (2.3.x) and newer versions, including the Master branch, a 64-bit E Nvironment is required. Older versions can be compiled on 32-bit systems.

Suppose you compile more than 2.3 of the version number, you will install the 64-bit Ubuntu system. Otherwise the 32-bit version number is available. I'm compiling the 2.3.5 version number, so choose the 32-bit version number of Ubuntu 12.04.5 LTS. Memory 3g. Hard drive 40g (the official website recommended is 30G above).


2. Installing the JDK

A lot of information on the Internet http://www.oracle.com official website to download, and then I also go silly underground download, downloaded the latest version number 1.8 above, the results were later executed when found Andorid use is jdk1.6 , The jdk1.6 must therefore be installed.

The compiled presentation sample is as follows:

Your version Is:java version "1.6.0_24". The correct version Is:java SE 1.6

In http://www.oracle.com/technetwork/java/javase/downloads/java-archive-downloads-javase6-419409.html

Download Jdk-6u33-linux-i586.bin, then move it to the Linux folder and I'll move to/usr/lib.

2.1 Assigning Permissions chmod +x Jdk-6u33-linux-i586.bin

2.2 Unzip ./jdk-6u33-linux-i586.bin

Confirmed all the way down. Finally extract the Jdk1.6.0_33 directory

2.3 Configuration

sudo update-alternatives--install "/usr/bin/java" "java" "/usr/lib/jdk1.6.0_33/bin/java "1
sudo update-alternatives--install "/usr/bin/javac" "Javac" "/usr/libjdk1.6.0_33/bin/javac "1
sudo update-alternatives--install "/usr/bin/javaws" "Javaws" "/usr/lib/jdk1.6.0_33/bin/javaws "1
sudo update-alternatives--install "/usr/bin/jar" "Jar" "/usr/lib/jdk1.6.0_33/bin/jar "1
sudo update-alternatives--config java

Assuming that your machine is already loaded with another version number of Java, this time will let you choose the Java version to be effective, remember to choose the current version of this 1.6

2.4 Change Environment variables:

sudo gedit/etc/environment

Export java_home=/usr/lib/jdk1.6.0_33
Export JRE_HOME=${JAVA_HOME}/JRE
Export Classpath=.:${java_home}/lib:${jre_home}/lib
Path= "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:${java_home}/bin:${jre_home}/bin "

sudo gedit/etc/profile

Export java_home=/usr/lib/jdk1.6.0_33
Export JRE_HOME=${JAVA_HOME}/JRE
Export Path=${java_home}/bin:${jre_home}/bin:${path}
Export classpath=.: $JAVA _home/lib: $JRE _home/lib: $CLASSPATH


2.5.source/etc/profile

Source/etc/environment


2.6.check Java version

Java-version

Get

Java Version "1.6.0_33"
Java (TM) SE Runtime Environment (build 1.6.0_33-b04)
Java HotSpot (TM) Client VMs (build 20.8-b03, mixed mode, sharing)


3. Download Android source code

A lot of online tutorials are networked download, but because of the well-known reasons, this method may be wall or very slow, I searched the Web site source code download. I downloaded the source code for 2.3.5 android2.3.5_kernel.7z. After extracting the. Tar, continue to extract the Mydroid directory, this is the source code, the same source code moved to/usr/lib

Go to the Source code folder and enter make. There will be very much output.

One of the problems I encountered:

< Span style= "Color:rgb (51,51,51); font-family:arial; font-size:16px; Line-height:26px ">frameworks/base/libs/utils/refbase.cpp: in member function ' void Android::refbase::weakref_type::trackme ( BOOL, BOOL) ' Medium:
frameworks/base/libs/utils/refbase.cpp:483:67: Error: ' const Android::refbase::weakref_impl ' as ' The ' this ' argument of void Android::refbase::weakref_impl::trackme (bool, BOOL) ' was discarded when the type qualification [-fpermissive]


This is due to the fact that the GCC version number is too high to be replaced with the appropriate version number to compile Android.


sudo apt-get install gcc-4.4

sudo apt-get install g++-4.4

sudo rm-rf/usr/bin/gcc/usr/bin/g++

sudo ln-s/USR/BIN/GCC-4.4/USR/BIN/GCC

sudo ln-s/usr/bin/g++-4.4/usr/bin/g++


The first compilation would be much longer, I was to let it run all night, and the next morning to get up and see the output

Target system FS Image:out/target/product/generic/obj/packaging/systemimage_intermediates/system.imgInstall system FS Image:out/target/product/generic/system.imgTarget Ram disk:out/target/product/generic/ramdisk.imgTarget UserData FS image:out/target/product/generic/userdata.imginstalled file List:out/target/product/generic/installed-files.txt

The source code was compiled on behalf of successful make.

4. Compiling the Linux kernel

Then we need to compile the Android Linux kernel, although it is the Linux source code, but can not casually from the online Linux source code, because Android in the Linux kernel based on the addition of its own unique drivers, So the Linux kernel to compile Android must use the Android dedicated Linux kernel. There are many ways to download a Git Clonehttp://android.googlesource.com/kernel/goldfish.git method on the Internet. But because of the wall it is not good to use. I searched for half a day and found a http://pan.baidu.com/s/1qW0TkkO here to download. About 300 m, much smaller than the source code.

After downloading, unzip the new folder kernel under the Android Source code folder. And put the extracted kernel source code under this folder

watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvy2hlbnp1amll/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/ Dissolve/70/gravity/southeast ">

There is also a need to make some changes to some parts of the makefile file to

ARCH = (subarch) cross_compile?=insteadARCH?

= Arm #体系结构为arm cross_compile? = arm-eabi- change path at the same time and join the cross-compilation environment. My (red part for compiling Android kernel required cross-compilation environment)
then run [email protected]:/usr/lib/mydroid2.3.5/kernel/common$ make goldfish_defconfig[email protected]:/usr in the kernel source code folder. /lib/mydroid2.3.5/kernel/common$ make

Finally, the output from Kernel:arch/arm/boot/zimage is ready proves that the kernel source code is compiled.

5, the implementation of the simulator to see the previous steps, this step is more convenient, first add the environment variable (red section, everyone according to their own placement path to make corresponding changes)

command line input [email protected]:/usr/lib/mydroid2.3.5$ emulator-kernel./kernel/common/arch/arm/boot/zimage &

The emulator will then start, enter the ADB shell into the Android system, continue to enter

Cd/proc

Cat version, you'll see your own compiled version number, like my example below

watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvy2hlbnp1amll/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/ Dissolve/70/gravity/southeast ">



All right, it's done.

Compiling Android source code and kernel summary

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.