How to compile android2.3 source code and build your own SDK in Ubuntu 10.04

Source: Internet
Author: User

I have updated a lot of things. Please go to the official website to check details. This article is outdated.

 

After a long time

I have read many articles on the Internet.

Finally, the source code of the ginger pie is compiled successfully.

To sum up

Or official articles.

Enter the subject

Share the complete steps and a simple method to modify the source code.

 

System:

The Ubuntu 64-bit version of ubuntu 10.04 lts (Ubuntu-10.04.2-desktop-amd64.iso) Wubi Installation

 

Configure the software source:

After the system is installed, you should first replace a fast software source

I use ubuntu.cn99.com.

Otherwise, downloading various updates and software packages is very slow.

 

Install and update:

Use the update manager to update the system to the latest version.

I installed flashplugin.

Skip this step.

 

Install JDK:

I want to compile the source code of 2.3 ginger pie, so JDK 6 is required (a 64-bit system is also required)

Installation Method:

Open Terminal

Input

Sudo add-Apt-repository "Deb http://archive.canonical.com/lucid partner"

Sudo add-Apt-repository "Deb-Src http://archive.canonical.com/ubuntu lucid partner"

Sudo apt-Get update

Sudo apt-Get install sun-java6-jdk

Just install it (Ubuntu 10.04 lts will bring those two sources)

You do not need to configure environment variables.

This step can refer to the http://source.android.com/source/initializing.html

 

Install various software packages:

Input in Terminal

Sudo apt-Get install Git-core GnuPG flex bison gperf build-essential zip curl zlib1g-dev libc6-dev lib32ncurses5-dev ia32-libs x11proto-core-dev libx11-dev lib32readline5-dev lib32z-dev libgl1-mesa-dev g ++-multilib mingw32 tofrodos texinfo libsdl-dev libwxgtk2.6-Dev

The last three are provided in the official documentation.

This step can refer to the http://source.android.com/source/initializing.html

 

Download source code:

Open the terminal and enter

Mkdir ~ /Bin

Path = ~ /Bin: $ path

In your personal folder, create a folder named bin and add it to the environment variable.

 

Enter

Curl https://android.git.kernel.org/repo> ~ /Bin/Repo

Chmod A + x ~ /Bin/Repo

First, download a repo file repo under the bin directory. In short, we use the repo file for Version Control to synchronize code.

 

Create a folder for storing the source code. my folder name is android2.3.

Input

Mkdir android2.3

CD android2.3

Go to the android2.3 directory

 

Input

Repo init-u git: // android.git.kernel.org/platform/manifest.git-B gingerbread

Indicates that the code you need is a ginger pie, so the last is gingerbread. If it is code 2.2, change gingerbread to froyo.

Then you need to enter your name and email address

If you cannot find the repo command, you need to reset the environment variable to the previous Path = ~ /Bin: $ path

 

Input

Repo sync

The process of starting Code Synchronization determines the speed based on your network speed.

The data to be downloaded in this step is as big as 3 GB.

It does not matter if the data can be resumed once.

 

If you have already performed the next operation, you only need to back up the projects folder in the hidden folder named. Repo under the source code directory (my name is android2.3 ).

Copy the projects folder back when synchronization is required.

CTRL + H view hidden files

 

This step can refer to the http://source.android.com/source/downloading.html

 

Compile the entire source code:

CD android2.3

Go to your code directory

Input

. Build/envsetup. Sh

Note. There is a space in the middle of the build.

Input

Lunch full-Eng

Make-J2

Input make to start compiling the code. Add the-J2 parameter to open two threads to compile the code faster. It took me two hours.

 

Input immediately after compilation

Emulator

The simulator can be run. If the system can run, the compilation is successful.

If you cannot find the emulator command

Environment variables need to be added

 

System. IMG is displayed in the out/target/product/generic folder under android2.3.

If you can see it, it should be successful.

This step can refer to the http://source.android.com/source/building.html

 

Compile the SDK:

This step is not described on the official website.

But in the source code folder, the document mentioned

The file howto_build_sdk.txt in the android2.3/SDK/docsdirectory describes how to compile the SDK.

Original

Then once you have all the source, simply build the SDK using:  $ cd ~/my-android-git  $ . build/envsetup.sh  $ lunch sdk-eng  $ make sdk

It seems that you do not need to compile the entire system before compiling the SDK. You can compile the SDK directly.

Enter as prompted

You can also add the-J parameter for make-J2 SDK.

However, it is not recommended that the SDK compilation fails easily and it takes more than 20 minutes to complete.

When

Package SDK: out/host/darwin-x86/sdk/android-sdk_eng.<build-id>_mac-x86.zip

<Build-ID> is the user name of the system by default.

The ADT plugin compilation is also mentioned in howto_build_sdk.txt.

I found that the ADT plug-in compiled by myself could not recognize platform's Own compilation to the SDK.

Unknown reason

You only need to use the official SDK and ADT.

Specifically, you can compile your own platform and copy it to the official SDK and go to the platforms folder for Android development.

Finally:

A very simple step

You can directly modify the source code and compile the SDK to get your own SDK.

I will demonstrate a simple example.

First, I found the textview code.

In frameworks/base/CORE/Java/Android/widget

I added a system. Out. println statement at the beginning of the updatetextcolors method.

Printed a sentence "Source code changed"

The updatetextcolors method is called in the settextcolor method of textview.

Save

Compile

Then use this platform

Create a project

Call the settextcolor method of textview to check the effect.

A simple example

Look

Source code changed is output

SDK modified

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.