Ubuntu 12.0 64位源码编译Android4.0 联系客服

发布时间 : 星期三 文章Ubuntu 12.0 64位源码编译Android4.0更新完毕开始阅读52813b61f5335a8102d220b0

Ubuntu 12 64位编译Android 4.0.1源码问题和解决办法

系统满足的条件:

在VMware下,最好给客户虚拟机1.5G内存,30G以上的硬盘。 实现应该要安装的软件:

For Gingerbread (2.3.x) and newer versions, including the master branch, a 64-bit environment is required. Older versions can be compiled on 32-bit systems.

Note: It is also possible to build Android in a virtual machine. If you are running Linux in a virtual machine, you will need at least 16GB of RAM/swap and 30GB or more of disk space in order to build the Android tree.

Detailed instructions for Ubuntu and MacOS follow. In general you will need:

? ? ? Python 2.5 -- 2.7, which you can download from python.org. GNU Make 3.81 -- 3.82, which you can download from gnu.org, JDK 6 if you wish to build Gingerbread or newer; JDK 5 for Froyo or older. You can download both from java.sun.com. ? Git 1.7 or newer. You can find it at git-scm.com. You will need a 64-bit version of Ubuntu. Ubuntu 10.04 is recommended. Building using a newer version of Ubuntu is currently only experimentally supported and is not guaranteed to work on branches other than master.

$ sudo apt-get install git-core gnupg flex bison gperf build-essential \\ zip curl libc6-dev libncurses5-dev:i386 x11proto-core-dev \\ libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-glx:i386 \\ libgl1-mesa-dev g++-multilib mingw32 openjdk-6-jdk tofrodos \\ python-markdown libxml2-utils xsltproc zlib1g-dev:i386

$ sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/libGL.so

源码编译过程中可能出现的问题: 1、

make: *** [out/host/linux-x86/obj/STATIC_LIBRARIES/libutils_intermediates/RefBase.o] Error 1 make: *** 解决方法:

gedit frameworks/base/libs/utils/Android.mk

LOCAL_CFLAGS += -DLIBUTILS_NATIVE=1 $(TOOL_CFLAGS) 修改为:

LOCAL_CFLAGS += -DLIBUTILS_NATIVE=1 $(TOOL_CFLAGS) –fpermissive 2、 make: ***

[out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/noproguard.classes-with-local.dex] Killed

解决方法:

把虚拟机ubuntu系统分配内存1G,有条件最好对于1G 3、

:0:0: error: \

make: *** [out/host/linux-x86/obj/EXECUTABLES/obbtool_intermediates/Main.o] Error 1 解决方法:

修改build/core/combo/HOST_linux-x86.mk 61行,将 HOST_GLOBAL_CFLAGS += -D_FORTIFY_SOURCE=0 修改成

HOST_GLOBAL_CFLAGS += -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0

昨天下载、编译了android-4.0.3,遇到的问题贴出来,共享一下: 环境要求改变。

现在要求内存1.5G左右,硬盘25G以上,以前1G、10G就够了。官方说明“Note: The source download is approximately 6GB in size. You will need 25GB free to complete a single build, and up to 80GB (or more) for a full set of builds.” 可惜我编之前没看,编译报错如下: 错一:

host SharedLib: libbcc (out/host/linux-x86/obj/lib/libbcc.so) collect2: ld terminated with signal 9 [Killed]

make: ***

[out/target/common/obj/JAVA_LIBRARIES/core_intermediates/noproguard.classes-with-local.dex] Killed

make: *** Waiting for unfinished jobs….

make: *** [out/host/linux-x86/obj/EXECUTABLES/llvm-rs-cc_intermediates/llvm-rs-cc] Error 1

collect2: ld terminated with signal 9 [Killed] collect2: ld terminated with signal 9 [Killed]

make: *** [out/host/linux-x86/obj/lib/libbcc.so] Error 1

make: *** [out/host/linux-x86/obj/EXECUTABLES/clang_intermediates/clang] Error 1 weihongcsu@ubuntu:~/disk2/android-4.0.1_r1$ 错二:

target Dex: framework make: ***

[out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/noproguard.classes-with-local.dex] Killed

weihongcsu@ubuntu:~/disk2/android-4.0.1_r1$ 错三:

arm-eabi-g++: Internal error: Killed (program cc1plus) 解决办法:

这些错误都是 linux的OOM killer 导致,“内存1.5G左右,硬盘25G”就可以解决,我为了保险,把make -j4改成了make.编译5个小时以上吧,out目录大小:12G。

错误1:

USER-NAME@MACHINE-NAME:~/Android$ make 出现了如下错误:

host C++: llvm-rs-cc <= frameworks/compile/slang/slang_rs_export_foreach.cpp

frameworks/compile/slang/slang_rs_export_foreach.cpp: In static member function ‘static slang::RSExportForEach* slang::RSExportForEach::Create(slang::RSContext*, const clang::FunctionDecl*)’:

frameworks/compile/slang/slang_rs_export_foreach.cpp:247:23: error: variable ‘ParamName’ set but not used [-Werror=unused-but-set-variable] cc1plus: all warnings being treated as errors make: *** [out/host/linux-x86/obj/EXECUTABLES/llvm-rs-cc_intermediates/slang_rs_export_foreach.o] Error 1

解决方法:

1.在工程根目录下,打开下面的makefile文件:

$ vi frameworks/compile/slang/Android.mk

2.在打开的makefile文件中按照下面更改:

#local_cflags_for_slang := -Wno-sign-promo -Wall -Wno-unused-parameter -Werror local_cflags_for_slang := -Wno-sign-promo -Wall -Wno-unused-parameter

错误2:

<命令行>:0:0: 错误:“_FORTIFY_SOURCE”重定义 [-Werror] :0:0: 附注:这是先前定义的位置

解决:

修改build/core/combo/HOST_linux-x86.mk 61行,将 HOST_GLOBAL_CFLAGS += -D_FORTIFY_SOURCE=0 修改成 HOST_GLOBAL_CFLAGS += -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0

错误2: host Prebuilt: monkeyrunner (out/host/linux-x86/obj/EXECUTABLES/monkeyrunner_intermediates/monkeyrunner) host C++: obbtool <= frameworks/base/tools/obbtool/Main.cpp <命令行>:0:0: 错误:“_FORTIFY_SOURCE”重定义 [-Werror] :0:0: 附注:这是先前定义的位置 cc1plus:所有的警告都被当作是错误

解决: 修改build/core/combo/HOST_linux-x86.mk 将 HOST_GLOBAL_CFLAGS += -D_FORTIFY_SOURCE=0 修改成 HOST_GLOBAL_CFLAGS += -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0

错误3:

error: Exited sync due to fetch errors 解决:

重新运行 repo sync 就可以解决

1、问题一:/bin/bash: bison: 未找到命令 解决方法:$ sudo apt-get install bison

2、问题二:

You are attempting to build with the incorrect version of java. Your version is: /bin/bash: java: 未找到命令. The correct version is: 1.5. 解决方法:

注意:必须使用1.5的JDK版本。不能使用1.6等其他版本。 (1)下载

在sun官网上下载jdk-1_5_0_22-linux-i586.bin。注意不是jdk-1_5_0_22-linux-i586rpm.bin (2)部署