1,上述都是ubuntu 64bit版本,他们编译android主要差异主要是gcc/g++,以及相关支持库的版本问题
2,ubuntu 10.04可以完美编译android 4.0.4和android 4.2的源代码
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 imagemagick
3,ubuntu 12.04编译android 4.0.4版本的时候,会出现若干报错,因为gcc版本为4.6,直接用如下方法,将gcc更新为4.4版本
环境安装包:
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 xsltproc lib32readline-gplv2-dev lib32z1-dev libxml2-utils imagemagick
sudo apt-get install gcc-4.4 gcc-4.4-multilib g++-4.4 g++-4.4-multilib
sudo rm -rf /usr/bin/gcc /usr/bin/gcc
sudo rm -rf /usr/bin/gcc /usr/bin/g++
sudo ln -s /usr/bin/gcc-4.4 /usr/bin/gcc
sudo ln -s /usr/bin/g++-4.4 /usr/bin/g++
这个时候是可以编译通过的,android4.2应该也可以编译通过,就没有做进一步测试了
4,ubuntu 13.04编译android 4.0.4版本的时候,会出现若干报错,因为gcc版本为4.7,直接用上述安装包以及修改方法,将gcc更新为4.4版本,但是仍然如下问题
a,会编译不通过:
dalvik/vm/native/dalvik_system_Zygote.cpp: In function ‘int setrlimitsFromArray(ArrayObject*)’: dalvik/vm/native/dalvik_system_Zygote.cpp:199:19: error: aggregate ‘setrlimitsFromArray(ArrayObject*)::rlimit rlim’ has incomplete type and cannot be defined struct rlimit rlim;
dalvik/vm/native/dalvik_system_Zygote.cpp:222:43: error: ‘setrlimit’ was not declared in this scope err = setrlimit(contents[0], &rlim);
make: *** [out/host/linux-x86/obj/SHARED_LIBRARIES/libdvm_intermediates/native/dalvik_system_Zygote.o] Error 1 make: *** Waiting for unfinished jobs....
所以,这个问题只能修改源代码来解决
在dalvik/vm/native/dalvik_system_Zygote.cpp中间增加一个头文件定义
#include "Dalvik.h"
#include "native/InternalNativePriv.h"
#include <sys/resource.h>
b,一个问题是有一处少了一个头文件,原因是zlib1g-dev有个头文件修改了路径,及zconf.h放到了/usr/include/x86_64-linux-gnu/,所以将其拷贝到/usr/include/下即可了
In file included from system/extras/ext4_utils/output_file.c:30:
/usr/include/zlib.h:34: fatal error: zconf.h: 没有那个文件或目录
compilation terminated.
这样,在ubuntu 13.03都可以编译通过了