Obtain 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 is in Ubuntu 11.04 get and compile the android 2.3.3 source code, the process of reference to the easwy blog http://easwy.com/blog/archives/compile-android-gingerbread-2-3-1/ 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 resume 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. Here I have tried two methods.

Method 1 (online ):

Run

sudo apt-get install sun-java6-jdk

Tip:

E: Package 'sun-java6-jdk' has no installation candidate

The software source provided by later versions of Ubuntu has changed. The solution is as follows:

$sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner"
$sudo add-apt-repository "deb-src http://archive.canonical.com/ubuntu lucid partner"

 

When the second command is executed, a prompt is displayed:

Error: 'deb-src http://archive.canonical.com/ lucid partner' invalid

Directly ignore this and continue:

sudo apt-get update
sudo apt-get install sun-java6-jdk

Installation starts.

Method 2 (offline ):

Reference Web site http://jayghost.iteye.com/blog/1245095

Download jdk-6u29-linux-i586.bin from official website

sudo chmod u+x jdk-6u29-linux-i586.bin

Modify the binfile permission to make it executable.
Then execute

./jdk-6u29-linux-i586.bin

Press the Enter key and decompress JDK to the folder to get JDK 1.6.0 _ 29. JDK installation is complete.

Configure the environment variables.

Add the following code to/etc/profile:

Java_home =/usr/Java/jdk1.6.0 _ 29
Path = $ java_home/bin: $ path
Classpath =.: $ java_home/lib/tools. jar: $ java_home/lib/dt. Jar
Export path classpath

PS: Copy JDK to/usr/Java.

Save and restart.

Use Java-version for verification.

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 Time Time Current
Dload Upload Total Spent Left Speed
100 19731 100 19731 0 0 14034 0 0:00:01 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 Time Time Current
Dload Upload Total Spent Left Speed
100 244 100 244 0 0 75 0 0:00:03 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
...

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.

The above is the whole process of downloading the source code. Please contact us for correction.

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.