Compile Android source code

Source: Internet
Author: User

First, build the android compiling environment.

(1) install and configure Java 5

1. install Java 6 First (Java 5 is required for Android compilation. This is recommended here)

Open the terminal, run the following command, or use adept/new software manager, where search for "sun-java6-jre" and "sun-java6-jdk" and tag the installation.

Sudo apt-Get install sun-java6-jre
If the space is rich, we recommend that you install a JDK.

Sudo apt-Get install sun-java6-jdk
Tip: During the installation process, you need to answer whether you agree to use the Protocol (the red-blue prompt page in the terminal). Press the tab key to OK, and press enter to install it normally.

2. install Java 5

If it is ubuntu910, update the source when installing Java 5. Method:

Place the following updates at the beginning of the update source.
Update Source: sudo gedit/etc/APT/sources. List
Deb http://cn.archive.ubuntu.com/ubuntu/ jaunty multiverse
Deb http://cn.archive.ubuntu.com/ubuntu/ jaunty-Updates multiverse

 

Sudo apt-Get install sun-java5-jre

Sudo apt-Get install sun-java5-jdk

3. Set the current default Java interpreter and compiler: (skip this step if multiple Java virtual machines are not installed in ubuntu9.10 .)

Sudo Update-alternatives -- config Java
The following figure is displayed after execution:

There are 2 alternatives which provide `java'.

Selection Alternative
-----------------------------------------------
+        1    /usr/lib/jvm/java-6-openjdk/jre/bin/java
          2    /usr/lib/jvm/java-6-sun/jre/bin/java
*         3    /usr/lib/jvm/java-1.5.0-sun/jre/bin/java
Press enter to keep the default[*], or type selection number:

Enter the number before the row containing "Sun. As shown above, enter 3 and press enter to confirm. (Java 5 needs to be configured to compile Android)

sudo update-alternatives --config javac

The operation is similar to the previous one.

4. Configure Java environment variables:

     sudo gedit /etc/environment

Add the following two lines:

     JAVA_HOME=/usr/lib/jvm/java-1.5.0-sun
     ANDROID_JAVA_HOME=$JAVA_HOME
     CLASSPATH=.:/usr/lib/jvm/java-1.5.0-sun/lib

To make the configuration take effect, you must restart the machine or enter

     . /etc/environment

5. Configure the JVM priority: (skip this step if multiple Java virtual machines are not installed in ubuntu9.10 .)

     sudo gedit /etc/jvm

Convert

     /usr/lib/jvm/java-1.5.0-sun

Enter this line at the top of the configuration block.

 

(2) install cross-compiler and other compilation tools

 

1.1.1 flex

Flex is a tool for generating scanners.

# Sudo apt-Get install flex

1.1.2 bison

Bison is a general-purpose Parser Generator.

# Sudo apt-Get install bison

 

1.1.3 gperf

Gperf is a program that generates perfect hash functions.

# Sudo apt-Get install gperf

 

1.1.4 libsdl-Dev

SDL is a library that allows programs portable low level access to a video framebuffer, audio output, mouse, and keyboard.

# Sudo apt-Get install libsdl-Dev

1.1.5 libesd0-devl

This program is designed to mix together several digitized audio streams for playback by a single device.

# Sudo apt-Get install libesd0-dev

 

1.1.6 libwxgtk2.6-Dev

This package provides files needed to compile wxWidgets programs.

# Sudo apt-Get install libwxgtk2.6-Dev

 

1.1.7 zlib1g-dev

Zlib is a library implementing the deflate compression method.

# Sudo apt-Get install zlib1g-dev

 

1.1.8 build-essential

This package contains an informational list of packages which are considered essential for building Debian packages.

# Sudo apt-Get install build-essential

 

1.1.9 libncurses5-dev

This package contains the header files, static libraries and symbolic links.

# Sudo apt-Get install libncurses5-dev

1.1.10 uboot-mkimage

This package contains the mkimage utility.

# Sudo apt-Get install uboot-mkimage

 

1.2 cross Tool

1. Copy the cross tool package to/usr/local/ARM

If the arm directory is not exist in host PC then create the Directory

# Mkdir/usr/local/ARM

# Cp 4.3.1-eabi-armv6-20080707.tar.bz2/usr/local/ARM

2. Unzip the code using tar command

# Tar xvjf 4.3.1-eabi-armv6-20080707.tar.bz2

 

3. Add Source Path in your environment file

# Vi ~ /. Bashrc

Add the Source Path

Path = $ path:/usr/local/ARM/4.3.1-eabi-armv6/usr/bin

# Source ~ /. Bashrc

 

4 unzip the code using tar command

# Tar xvjf cross-4.2.2-eabi.tar.bz2-C/usr/local/ARM

 

 

1.3 build android

1. Use the tar command to extract the source code to a path /.

2. Move to Android directory and build it.

# Cd path/Android (this is the path after you extract the android source code)

# Make (this step is for compilation and may take a long time)

Bytes -------------------------------------------------------------------------------------------------------------

How to debug the android source code in eclipse tomorrow

 

Related Article

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.