在Ubuntu 11.04系统 32位机上下载、编译Android 2.3源码,其步骤和注意事项如下:
1.安装JDK6
对于Android2.3系统,不要安装JDK5,应该安装最新的JDK6。
如果安装了JDK6,Android会自动按64位编译,如果系统是32位的,会有编译错误,后面会说如何修改这个错误。
sudo add-apt-repository "deb lucid partner"
sudo add-apt-repository "deb lucid partner"
//为系统增加源
sudo apt-get update
sudo apt-get install sun-java6-jdk
sudo update-java-alternatives -s java-6-sun
拷贝的源码出现:
chengyake@chengyake:~/android2.3$ sudo update-java-alternatives -s java-6-sun
[sudo] password for chengyake:
update-alternatives: 错误: 无 mozilla-javaplugin.so 的候选项。
update-alternatives: 错误: 无 xulrunner-1.9-javaplugin.so 的候选项。
update-alternatives: 错误: 无 mozilla-javaplugin.so 的候选项。
update-alternatives: 错误: 无 xulrunner-1.9-javaplugin.so 的候选项。
安装完后,需要手动设置JAVA_HOME, JRE_HOME, CLASS_PATH为JDK6的安装路径。
2. 安装各种包
$ sudo aptitude install git-core gnupg flex bison gperf libsdl-dev libesd0-dev libwxgtk2.6-dev build-essential zip curl libncurses5-dev zlib1g-dev
3. 安装Repo(repo就是一个脚本而已,帮助我们使用git)
$ mkdir ~/bin
$ export PATH=~/bin:$PATH
$ curl > ~/bin/repo
$ chmod a+x ~/bin/repo
$ mv repo /bin
4.下载Android源码
$mkdir ~/Android2.3
$cd ~/Android2.3
$ repo init -u git://Android.git.kernel.org/platform/manifest.git
$ repo sync
这一步持续时间很长,看网速吧,我这边儿600K左右,也就下了两个多小时
5. 编译Android2.3
先export Android_JAVA_HOME=$JAVA_HOME
$ cd ~/Android2.3
$ source build/envsetup.sh
拷贝的源码出现:
chengyake@chengyake:~/android2.3$ source build/envsetup.sh
including device/htc/passion/vendorsetup.sh
including device/samsung/crespo4g/vendorsetup.sh
including device/samsung/crespo/vendorsetup.sh
including sdk/bash_completion/adb
including sdk/bash_completion/MODULE_LICENSE_APACHE2
including sdk/bash_completion/NOTICE
bash: sdk/bash_completion/NOTICE: 行 2: 未预期的符号 `c' 附近有语法错误
bash: sdk/bash_completion/NOTICE: 行 2: ` Copyright (c) 2011, The Android Open Source Project'
including sdk/bash_completion/README
This:找不到命令
bash: sdk/bash_completion/README: 行 2: 未预期的符号 `(' 附近有语法错误
bash: sdk/bash_completion/README: 行 2: `Bourne Again SHell (bash)'s programmable completion.'
//进入到build内souce envsetup。h就可以
$ lunch
$ make
在make的时候会提示出错:
************************************************************
You are attempting to build on a 32-bit system.
Only 64-bit build environments are supported beyond froyo/2.2.
************************************************************
因为Android2.3默认是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
重新make,如果是安装了JDK6版本,会又报错:
Docs droiddoc: out/target/common/docs/api-stubs
Could not load ‘clearsilver-jni’
java.library.path = out/host/linux-x86/lib
make: *** [out/target/common/docs/api-stubs-timestamp] Error 45
make: *** Waiting for unfinished jobs….
Could not load ‘clearsilver-jni’
java.library.path = out/host/linux-x86/lib
make: *** [out/target/common/docs/doc-comment-check-timestamp] Error 45
这是由于clearsilver在编译时如果检测到使用Java JDK 6,就使用64位编译,因为Google的一个员工更新了几个文件。这里可以看到详细的修改记录: a=commitdiff;h=d36910a8110d8377b22301274d2b5131a732a72b
修改这几个文件,该回到32位编译环境即可:
external/clearsilver/cgi/Android.mk
external/clearsilver/java-jni/Android.mk
external/clearsilver/util/Android.mk
external/clearsilver/cs/Android.mk
把编译选项-m64改成-m32即可
重新make,大概不到一个小时就make完了。
阅读(2310) | 评论(0) | 转发(2) |