yinbaoshiguang 2011-03-12
1. 环境
Ubuntu 10.04 32-bit
sudo apt-get install git-core
sudo apt-get install curl
sudo apt-get install zlib -dev 变为 sudo apt-get install zlib1g -dev
sudo apt-get install bison
sudo apt-get install flex
sudo apt-get install libncurses-dev (libncurses5-dev)
sudo apt-get install g++
sudo apt-get install libx11-dev
sudo apt-get install gperf
安装Java6
关于Java版本:Java6能够编译代码,但不能生成文档,最好准备两套Java环境
Ubuntu 10.04 64-bit
sudo apt-get install libc6-dev-i386
sudo apt-get install lib32ncurses5-dev
sudo apt-get install libx11-dev
sudo apt-get install g++-multilib
sudo apt-get install lib32z1-dev
64-bit Java6
2. 下载Android SDK
curl http://android.git.kernel.org/repo > ~/bin/repo
chmod a+x ~/bin/repo
获取eclair代码:
repo init -u http://android.git.kernel.org/platform/manifest.git -b eclair
从Android 2.2开始,编译SDK需要64位系统,32位的,只好先编译Eclair了.
repo init -u http://android.git.kernel.org/platform/manifest.git -b eclair
repo sync
3. 编译
make
cd eclair
. ./build/envsetup.sh
make sdk
最后,同步这些变化:
$ source ~/.bashrc
$ cd ~/android/out/target/product/generic
$ emulator -system system.img -data userdata.img -ramdisk ramdisk.img
最后进入android桌面,就说明成功了。
4. 编译模块
android中的一个应用程序可以单独编译,编译后要重新生成system.img
在源码目录下执行
$ . build/envsetup.sh (.后面有空格)
就多出一些命令:
- croot: Changes directory to the top of the tree.
- m: Makes from the top of the tree.
- mm: Builds all of the modules in the current directory.
- mmm: Builds all of the modules in the supplied directories.
- cgrep: Greps on all local C/C++ files.
- jgrep: Greps on all local Java files.
- resgrep: Greps on all local res/*.xml files.
- godir: Go to the directory containing a file.
可以加—help查看用法
我们可以使用mmm来编译指定目录的模块,如编译联系人:
$ mmm packages/apps/Contacts/
编完之后生成两个文件:
out/target/product/generic/data/app/ContactsTests.apk
out/target/product/generic/system/app/
5. 直接执行make是不包括make sdk的。make sdk用来生成SDK,这样,我们就可以用与源码同步的SDK来开发android
sudo apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common