Friday, October 31, 2008

Create Android build code environment on Ubuntu

[install essential application]
$ sudo apt-get install python2.5
$ sudo apt-get install sun-java5-jdk
$ sudo apt-get install sun-java5-bin
$ sudo apt-get install sun-java5-jre
Add/Edit /etc/bash.bashrc
export JAVA_HOME=/usr/lib/jvm/java-5-sun-1.x.x.xx (as your Java folder name)
$ sudo apt-get install flex
$ sudo apt-get install bison
$ sudo apt-get install gperf
$ sudo apt-get install libsdl-dev
$ sudo apt-get install libesd0-dev
$ sudo apt-get install libwxgtk2.6-dev
$ sudo apt-get install build-essential
$ sudo apt-get install g++
$ sudo apt-get install zip
$ sudo apt-get install curl
$ sudo apt-get install valgrind
$ sudo apt-get install zlib1g-dev
$ sudo apt-get install libncurses5-dev

[Installing Git and Repo]
$ cd ~
$ mkdir bin

Add ~/bin to your PATH
Add/Edit /etc/bash.bashrc
export PATH=$PATH:~/bin

$ sudo apt-get install git-core gnupg

Logout and check
$ echo $PATH
$ echo $JAVA_HOME

$ curl > ~/bin/repo
$ chmod a+x ~/bin/repo

Create an empty directory in ~/bin to hold your working files:
$ mkdir mydroid
$ cd mydroid

$ repo init -u git://
(need about 1698KB and 1 minute)

When prompted, configure Repo with your real name and email address.
If you plan to submit code, use an email address that is associated with a Google account.

A successful initialization will end with a message such as $ repo initialized in /mydroid

[Get source]
$ repo sync
(need about 1.56GB and 43 minutes)

If you meet the "error : Cannot fetch platform/external/webkit" use below command to revole it.

rm -rf .repo/projects/external/webkit.git external/webkit
cd .repo/manifests
git pull
cd ../../
repo sync

[Build code]
To build the files, run make from within your working directory:
$ cd ~/mydroid
$ make
(need about 1.85GB and 94 minutes)

[Check if success]
cd ~/bin/mydroid/out/target/product/generic/
If success, three files ramdisk.img, system.img, and userdata.img should be in this folder.

total need about 3.42GB

[Use emulator image]
copy ~/bin/mydroid/out/target/product/generic/
to Android SDK folder "android-sdk-windows-1.0_r1\tools\lib\images"
Start emulator.

1. can not find by apt-get install:
   a. Reomve comments some URL in /etc/apt/sources.list ,run 'sudo apt-get update' to get the latest package information.
   b. If you back to proxy,setting it in /etc/apt/apt.conf
http::Proxy "http://[username]:[password]";

2. Set default language to english:System -> Administration -> Language Support -> Default language -> English,reboot,系統會詢問是否將預設的資料夾由中文改成英文,選擇改成英文。

3.  If you want to share the source code, remember chmod 644 for below files:


1. Build on Ubuntu 8.04
2. Get source in Android offcial website
3. How to use emulator image?

No comments:

Post a Comment

You can leave any question here and I will make a response to you ASAP. :D