Android Source Compilation Summary

Source: Internet
Author: User

These smallpox took some time to download the Android source code to compile, which took some detours lead to a bit of time, and now re-comb the summary, so that people have the same idea 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, installed VMware virtual machine, ubuntu-12.04 on the virtual machine, my version is 32 bits , this is quite important, install 32-bit or 64-bit will determine the Android version you can compile, the official document For Gingerbread (2.3.x) and newer versions, including the Master branch, a 64-bit environment is required. Older versions can be compiled on 32-bit systems.

If you compile a version of 2.3 or more, install the 64-bit Ubuntu system, or the 32-bit version, I am compiling the 2.3.5 version, so choose the 32-bit version of Ubuntu 12.04.5 LTS. Memory 3g, hard disk 40g (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 of more than 1.8, the results later found that Andorid use is jdk1.6 , The jdk1.6 must therefore be installed.

The following tips are compiled:

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 directory, 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

Confirm all the way down, and finally extract the Jdk1.6.0_33 folder

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

If your machine is already loaded with other versions of Java, this will allow you to choose the Java version to take effect, and remember to select the current 1.6 version

2.4 To Modify an environment variable:

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

Many online tutorials are networked download, but for well-known reasons, this method may be wall or very slow, I searched the Web site source download, I downloaded the 2.3.5 source android2.3.5_ kernel.7z, extracted after decompression to get. Tar, continue to extract the Mydroid folder, this is the source code, the same code to move the source/usr/lib under

Enter the source directory, enter make, there will be a lot of 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-qualified [-fpermissive]


This issue is due to the fact that the version of the GCC is too high and needs to be replaced with the appropriate version that can be compiled for 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 longer, I was putting it on one night to let it run, and the next morning I got up and saw the 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.txtOn behalf of the successful make compiled the source code, applause encouraged under O (∩_∩) o haha ~.

Android Source Compilation 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.