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 .
GNU Make 3.81 -- 3.82, which you can download from ,
JDK 6 python虚拟机if you wish to build Gingerbread or newer; JDK 5 for Froyo or older. You can download both from java.sun.
Git 1.7 or newer. You can find it at git-scm.
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、
<command-line>:0:0: error: "_FORTIFY_SOURCE" redefined [-Werror]

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/noproguar
d.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

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。