1 准备开发环境,在Ubuntu下需要安装的软件包:
Git 1.5.4 or newer and the GNU Privacy Guard.
JDK 5.0, update 12 or higher.Java 6 is not supported, because of incompatibilities with @Override. //注意JDK版本为5.0
flex, bison, gperf, libsdl-dev, libesd0-dev, libwxgtk2.6-dev (optional), build-essential, zip, curl.
安装执行命令如下
$ sudo apt-get install git-core gnupg sun-java5-jdk flex bison gperf libsdl-dev libesd0-dev libwxgtk2.6-dev build-essential zip curl libncurses5-dev zlib1g-dev
另外可以安装valgrind.用于 find memory leaks, stack corruption, array bounds overflows等等。
在Ubuntu 9.10,直接使用$sudo apt-get install sun-java5-jdk时,安装java5会安装不成功,提示没有找到软件包。
需要在/etc/apt/sources.list-->“其它软件”中加入
deb dapper main multiverse
然后安装
$ sudo apt-get update
$ sudo apt-get install sun-java5-jdk
然后vi .bashrc增加java环境变量
JAVA_HOME=/usr/lib/jvm/java-1.5.0-sun
PATH=$JAVA_HOME/bin:$PATH
CLASSPATH=$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export JAVA_HOME
export PATH
export CLASSPATH
2 安装Repo
To install, initialize, and configure Repo, follow these steps:
1. Make sure you have a~/bindirectory in your home directory, and check to be sure that this bin directory is in your path:
$ cd ~
$ mkdir bin
$ echo $PATH
2. Download thereposcript and make sure it is executable:
$ curl >~/bin/repo
$ chmod a+x ~/bin/repo
3 Initializing a Repo client
# Create an empty directory to hold your working files:
$ mkdir mydroid
$ cd mydroid
# Run "repo init" to bring down the latest version of Repo with all its most recent bug fixes. You must specify a URL for the manifest:
$ repo init -u git://Android.git.kernel.org/platform/manifest.git
* If you would like to check out a branch other than "master", specify it with -b, like:
$ repo init -u git://android.git.kernel.org/platform/manifest.git -b cupcake //froyo
4 下载代码
$ repo sync
5 编译
$cd ~/mydroid
$make
如果编译失败,因为缺少"run-java-tool"
则$export ANDROID_JAVA_HOME=$JAVA_HOME