UBUNTU 10.10 需要的包
sudo apt-get install git-core gnupg flex bison gperf build-essential zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 lib32ncurses5-dev ia32-libs x11proto-core-dev libx11-dev lib32readline5-dev lib32z-dev java-common unixodbc
编译2.3.1需要Java 6 需要下面的源 编辑/etc/apt/sources.list
deb http://archive.canonical.com/ubuntu lucid partner
deb-src http://archive.canonical.com/ubuntu lucid partner
sudo apt-get install sun-java6-jdk
修改$JAVA_HOME的环境变量 /usr/lib/jvm/java-6-sun
接下来下载repo工具,这是Google提供的一个Python脚本,方便管理多个Git版本库:
$ cd ~
$ mkdir bin
$ curl http://android.git.kernel.org/repo >~/bin/repo
$ chmod a+x ~/bin/repo
记得把repo加到你的路径中,方便以后使用。编辑~/.bashrc,加入下面一行:
PATH=$PATH:~/bin
export PATH
接下来获取Android 2.3.1的源代码:
$ mkdir mydroid
$ cd mydroid
$ repo init -u git://android.git.kernel.org/platform/manifest.git -b android-2.3.1_r1
$ repo sync
接下来开始编译:
我是i5的cpu,4核
$ make -j4
或
$ make -j`grep '^processor' /proc/cpuinfo | wc -l`
我在编译的过程中遇到检测CPU字长是64位的问题
我直接把build/core/main.mk中下面的话注释掉:
#ifneq (64,$(findstring 64,$(build_arch)))
#$(warning ************************************************************)
#$(warning You are attempting to build on a 32-bit system.)
#$(warning Only 64-bit build environments are supported beyond froyo/2.2.)
#$(warning ************************************************************)
#$(error stop)
#endif
接下来又遇到找不到64位的头文件的错误:
需要修改下面四个文件:
external/clearsilver/cgi/Android.mk
external/clearsilver/java-jni/Android.mk
external/clearsilver/util/Android.mk
external/clearsilver/cs/Android.mk
把这四个Makefile中的下列语句注掉即可:
# This forces a 64-bit build for Java6
# Comment by Easwy
# LOCAL_CFLAGS += -m64
# LOCAL_LDFLAGS += -m64
然后在external/clearsilver目录中执行一下make clean,然后回到项目根目录,继续make即可。
====================================
编译SDK
make -j4 sdk
启动模拟器
进入生成的SDK image目录运行
./out/host/linux-x86/sdk/android-sdk_eng.root_linux-x86/platforms/android-2.3.1/images$ ../../../tools/emulator -image system.img -data userdata.img -ramdisk ramdisk.img