一、安装编译所需要的库
$sudo apt-get install build-essential libc6-dev lib32ncurses5-dev ia32-libs x11proto-core-dev libx11-dev lib32readline-gplv2-dev \ lib32z1-dev libgl1-mesa-dev gcc-multilib g++-multilib mingw32 tofrodos python-markdown libxml2-utils xsltproc \
git-core gnupg valgrind flex bison gperf libsdl-dev libesd0-dev libwxgtk2.6-dev zip curl libncurses5-dev zlib1g-dev \
gcc g++ libwxgtk2.8-dev liblzo2-dev
注意:
a.64位系统要安装gcc-multilib g++-multilib,32位系统不需要装. 上述库中32位库64位桌面版本可能无法安装,需要换源
二、安装sun-java6-jdk
安装sun-java6-jdk首先需要在源里添加sun-java6-jdk的源
安装jdk6
$sudo apt-get install python-software-properties
$sudo add-apt-repository "deb http://us.archive.ubuntu.com/ubuntu/ hardy multiverse"
$ sudo apt-get update
$ sudo apt-get install sun-java6-jdk
通过上两步的安装现在就可以编译android的源码了。
三、ubuntu 12.04 编译android2.3源码遇到的问题
1、error while loading shared libraries: libz.so.1:cannot open shared object file: No such file or directory
这个问题表示系統不知道libz.so.1,我们用命令locate libz.so.1看一下libz.so.1在那个目录下,
$locate libz.so.1
/lib/x86_64-linux-gnu/libz.so.1
/lib/x86_64-linux-gnu/libz.so.1.2.3.4
我们将/lib/x86_64-linux-gnu目录放到 /etc/ld.so.conf文件中 :include /lib/x86_64-linux-gnu
然后执行 sudo ldconfig -v 命令
2、编译错误"/usr/bin/ld: cannot find -lz"
缺少lib32z1-dev,安装即可:apt-get install lib32z1-dev
3、make: *** [out/host/linux-x86/obj/EXECUTABLES/obbtool_intermediates/Main.o] Error 1
解决方法:
修改源码目录下/build/core/combo/HOST_linux-x86.mk文件:
将以下语句
HOST_GLOBAL_CFLAGS += -D_FORTIFY_SOURCE=0
修改为
HOST_GLOBAL_CFLAGS += -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0
4、frameworks/base/libs/utils/RefBase.cpp: 在成员函数‘voidandroid::RefBase::weakref_type::trackMe(bool, bool)’中:
frameworks/base/libs/utils/RefBase.cpp:483:67: 错误: 将‘constandroid::RefBase::weakref_impl’作为‘voidandroid::RefBase::weakref_impl::trackMe(bool,bool)’的‘this’实参时丢弃了类型限定 [-fpermissive]
make: ***[out/host/linux-x86/obj/STATIC_LIBRARIES/libutils_intermediates/RefBase.o]错误 1
make: *** 正在等待未完成的任务....
解决:
gedit frameworks/base/libs/utils/Android.mk
Change the line:
LOCAL_CFLAGS += -DLIBUTILS_NATIVE=1 $(TOOL_CFLAGS)
To:
LOCAL_CFLAGS += -DLIBUTILS_NATIVE=1 $(TOOL_CFLAGS) –fpermissive