Obtain and compile the Android source code in ubuntu 11.04

Source: Internet
Author: User
Tags gnupg valgrind

 

In the past two days, we have started to prepare the source code compilation. In this case, we will record the process so that we can easily back up the source code and hope it will be helpful to the later users.

Attention: the environment in this article is to obtain and compile the source code of android 2.3.3 under ubuntu 11.04,

 

The process reference easwy's blog: http://www.bkjia.com/kf/201111/110741.html

And google official website http://source.android.com/source/downloading.html.

 

The requirements on the official website are:

In general you will need:

• Python 2.4 -- 2.7, which you can download from python.org.

• JDK 6 if you wish to build Gingerbread or newer; JDK 5 for Froyo or older. You can download both from java.sun.com.

• Git 1.5.4 or newer. You can find it at git-scm.com.

• (Optional) Valgrind, a tool that will help you find memory leaks, stack rollback uption, array bounds overflows, etc. Download from valgrind.org.

In addition: 6 GB or more disk space, dependent deb package: flex, bison, gperf, libsdl-dev, libesd0-dev, libwxgtk2.6-dev, build-essential, zip, curl

I. Preparations before downloading

First, after preparing the required disk space, install the required development kits and execute the following commands on the terminal:

$ Sudo apt-get install git-core gnupg flex bison gperf libsdl1.2-dev libesd0-dev libwxgtk2.6-dev build-essential zip curl libncurses5-dev zlib1g-dev

Here, you need to pay attention to two points: 1. libsdl version 1.2; 2. zlib1g-dev do not see the error is 1 rather than l, of course, not the hands of the tx there is no such problem.

Then you need to install the java environment and view the version directly on the terminal:

Wayne @ ubuntu :~ $ Java-version

The program "java" is included in the following software packages:

* Gcj-4.4-jre-headless

* Gcj-4.5-jre-headless

* Openjdk-6-jre-headless

Please try: sudo apt-get install <selected software package>

Input: sudo apt-get install openjdk-6-jre-headless, installation is OK, and then view the version:

Wayne @ ubuntu :~ $ Java-version

Java version "1.6.0 _ 22"

OpenJDK Runtime Environment (IcedTea6 1.10.2) (6b22-1.10.2-0ubuntu1 ~ 11.04.1)

OpenJDK Server VM (build 0-b11, mixed mode)

Jdk is installed.

Ii. Download source code

Now we have prepared the environment required for android source code development (no error). The process of downloading the source code is very huge because the Android source code needs to be obtained in two parts: Android source code and kernel. I don't need the source code of the kernel for the time being, so here I only download the source code.

1. Create a new folder to store the Android directory and initialize the repo:

Wayne @ ubuntu :~ $ Mkdir Android

Wayne @ ubuntu :~ $ Cd Android

Wayne @ ubuntu :~ /Android $ mkdir bin

Wayne @ ubuntu :~ /Android $ cd bin

Wayne @ ubuntu :~ /Android/bin $ curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo> repo

% Total % Received % Xferd Average Speed Time Current

Dload Upload Total Spent Left Speed

100 19731 100 19731 0 0 14034 0 0:00:01 --: -- 17157

 

Here, a few months ago:

Wayne @ ubuntu :~ /Android/bin $ curl http://android.git.kernel.org/repo> repo

% Total % Received % Xferd Average Speed Time Current

Dload Upload Total Spent Left Speed

100 244 100 244 0 0 75 0 0:00:03 --: -- 976

Then, the following error occurs during subsequent code initialization:

./Bin/repo: Row 1: Unexpected syntax error near the symbol 'newline'

./Bin/repo: Row 1: '<! Doctype html public "-// IETF // dtd html 2.0 // EN">'

2. continue now. Create and store the source code directory and initialize the required android source code version. Run the following command on the terminal:

Wayne @ ubuntu :~ /Android/bin $ sudo chmod a + x repo

Wayne @ ubuntu :~ /Android/bin $ cd

Wayne @ ubuntu :~ $ Cd Android/source/

Wayne @ ubuntu :~ /Android/source $ ../bin/repo init-u https://android.googlesource.com/platform/manifest-B android-2.3.3_r1

Gpg: the key ring '/home/wayne/. repoconfig/gnupg/secring. gpg' has been created.

Gpg: the key ring '/home/wayne/. repoconfig/gnupg/pubring. gpg' has been created.

Gpg:/home/wayne/. repoconfig/gnupg/trustdb. gpg: Build a trust Database

Gpg: Key 920F5C65: Public Key "Repo Maintainer <repo@android.kernel.org>" imported

Gpg: Total number of processed items: 1

Gpg: imported: 1

 

Get https://android.googlesource.com/tools/repo

Remote: Counting objects: 1414, done

Remote: Finding sources: 100% (78/78)

Remote: Total 1414 (delta 917), reused 1414 (delta 917)

Grouping objects: 100% (1414/1414), 429.88 KiB | 169 KiB/s, done.

Resolving deltas: 100% (917/917), done.

From https://android.googlesource.com/tools/repo

* [New branch] maint-> origin/maint

* [New branch] master-> origin/master

* [New branch] stable-> origin/stable

...Www.2cto.com

In this case, you are required to enter the user name and email address.

After initialization, the following error occurs:

Repo initialized in/home/wayne/Android/source

Now you can download the SDK after initialization. Run the following command on the terminal to download the SDK:

Wayne @ ubuntu :~ /Android/source $ ../bin/repo sync

It takes a long time to download all the source code, and now it is going through a long wait ......

During the process, you may encounter errors and interruptions:

Error: Exited sync due to fetch errors

If you encounter these problems, re-execute ../bin/repo sync and then OK.

 

Iii. Compile source code

The Compilation part should be recorded after the download is completed. It will be provided later.

Extracted from migrant workers with poor spirits

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.