分类: Android平台
2014-04-25 10:47:16
系统满足的条件:
在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:
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、
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]
解决:
修改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]
解决:
修改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)部署
进入jdk-1_5_0_22-linux-i586.bin所在目录
cd ~
赋予该bin文件可执行属性
chmod +x jdk-1_5_0_22-linux-i586.bin
一直回车跳过协议到最后一行:
Do you agree to the above license terms? [yes or no]
键入yes回车,开始解压。默认解压到当前目录下的jdk1.5.0_22目录里。
(3)配置环境变量
执行$gedit ~/.bashrc打开.bashrc文件。
修改./bashrc文件,在文件末尾添加
#set java environment
JAVA_HOME=“你的路径”/jdk1.5.0_10
export JRE_HOME=“你的路径”/jdk1.5.0_10/jre
export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH
保存并关闭文件。
在终端执行source ~/.bashrc刷新该配置
使用java –version检查JDK是否配置正确。
3、问题三:
host c++: libhost <= build/libs/host/pseudolocalize.cpp/bin/bash: g++: 未找到命令
make: ***[out/host/linux-x86/obj/STATIC_LIBRARIES/libhost_intermediates/pseudolocalize.o] 错误 127
解决方法:$ sudo apt-get install build-essential
4、问题四:
external/clearsilver/cgi/cgi.c:22:18: 致命错误: zlib.h: 没有那个文件或目录编译终端。
make: ***[out/host/linux-x86/obj/SHARED_LIBRARIES/libneo_cgi_intermediates/cgi.o] 错误 1
解决方法:$ sudo apt-get install zlib1g-dev
5、问题五:
make: ***[out/host/linux-x86/obj/EXECUTABLES/aapt_intermediates/appt] 错误 1
解决方法:
打开Android.mk文件
$gedit frameworks/base/tools/aapt/Android.mk
编辑下面一行:
ifeq ($(HOST_OS),linux)
#LOCAL_LDLIBS += -lrt 把这行注释掉,改为下面一行。
LOCAL_LDLIBS += -lrt -lpthread
endif
6、问题六:
host c: adb<= system/core/adb/fdevent.c
host Executable:adb (out/host/linux-86/obj/EXECUTABLES/adb_intermediates/adb)/user/bin/ld: cannot find –lncurses
collect2: ld 返回 1
make: ***[out/host/linux-86/obj/EXECUTABLES/adb_intermediates/adb] 错误 1
解决方法:$sudo apt-get install libncurses5-dev
7、问题七:
make: ***[out/target/product/sam9g45/obj/STATIC_LIBRARIES/libwebcore_intermediates/WebCore/css/CSSPropertyNames.h] 错误 25
解决方法:$sudo apt-get install gpert
8、问题八:
host C++: libutils <= frameworks/base/libs/utils/RefBase.cpp
frameworks/base/libs/utils/RefBase.cpp: In member function ‘void android::RefBase::weakref_type::trackMe(bool, bool)’:
frameworks/base/libs/utils/RefBase.cpp:483:67: error: passing ‘const android::RefBase::weakref_impl’ as ‘this’ argument of ‘void android::RefBase::weakref_impl::trackMe(bool, bool)’ discards qualifiers [-fpermissive]
make: *** [out/host/linux-x86/obj/STATIC_LIBRARIES/libutils_intermediates/RefBase.o] 错误 1
解决方法:
打开Android.mk
$ gedit frameworks/base/libs/utils/Android.mk
将下面这一行
LOCAL_CFLAGS += -DLIBUTILS_NATIVE=1 $(TOOL_CFLAGS)
改为
LOCAL_CFLAGS += -DLIBUTILS_NATIVE=1 $(TOOL_CFLAGS) -fpermissive
9、问题九:
make: ***[out/host/linux-x86/obj/EXECUTABLES/emulator_intermediates/android/skin/window.o] Error 1
解决方法:$ sudo apt-get install libx11-dev
10、问题十:
make: *** [out/host/linux-x86/obj/EXECUTABLES/localize_intermediates/localize] 错误 1
解决方法:
打开Android.mk:
$gedit ./framework/base/tools/localize/Android.mk文件(注意与问题五中的文件是不同文件)
编辑下面一行:
ifeq ($(HOST_OS),linux)
#LOCAL_LDLIBS += -lrt 把这行注释掉,改为下面一行。
LOCAL_LDLIBS += -lrt –lpthread
转载请注明出处:http://blog.csdn.net/pku_android
11、问题十一:
make: ***[out/host/linux-x86/obj/EXECUTABLES/accRuntimeTest_intermediates/accRuntimeTest] 错误 1
解决方法:
打开Android.mk:
$gedit system/core/libacc/tests/Android.mk(注意与问题五和问题十不是同一个文件)
将以下缺少的语句添加进去:
LOCAL_SHARED_LIBRARIES := \
libacc
LOCAL_LDLIBS += -ldl
LOCAL_MODULE_TAGS := tests
在include $(BUILD_HOST_EXECUTABLE)下面添加以下缺少的语句:
LOCAL_SHARED_LIBRARIES := \
libacc
LOCAL_LDLIBS += -ldl
LOCAL_MODULE_TAGS := tests
圣诞本来想去西单的,还是留在宿舍编译4.0源码,当前硬件 linux分区80G+4G swap,内存4G,i5 2430
环境配置这儿有,官方的说明那是。
编译遇到问题我都写出来了。
遇到的第一处错误
make: *** [out/host/linux-x86/obj/EXECUTABLES/obbtool_intermediates/Main.o] Error 1
此处编译错误是由于ubuntu 11.10采用了GCC4.6.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
并不会就这样结束,接下来你会发现有个地方你必须把gcc改为4.4的
第二处错误上场了
make: *** [out/host/linux-x86/obj/EXECUTABLES/llvm-rs-cc_intermediates/slang_rs_export_foreach
在工程根目录下,打开下面的makefile文件:
源码目录 frameworks/compile/slang/Android.mk
.在打开的makefile文件中按照下面更改:
#local_cflags_for_slang := -Wno-sign-promo -Wall -Wno-unused-parameter -Werror
local_cflags_for_slang := -Wno-sign-promo -Wall -Wno-unused-parameter
原因很简单把警告当作error处理,所以此处要修改
==============================================
继续编译,错误忘了,没记录。这儿需要修改cpp如下。详情可以到 groups看,错误应该有个linker什么的,看代码提示就行了
#include
to external/mesa3d/src/glsl/linker.cpp
=============================================
继续编译
make: *** [out/host/linux-x86/obj/EXECUTABLES/opannotate_intermediates/opannotate] 错误 1
解决方法:
HAVE_LIBBFD := false in external/oprofile/common.mk
ifeq ($(HOST_OS)-$(HOST_ARCH),linux-x86)
#onelong HAVE_LIBBFD := true 修改为:
HAVE_LIBBFD := false
===================================
最后你可能发现找不到-lstdc++ 悲剧。这个是在g++ mutillib中
lib64stdc++6-4.4-dbg gcc-4.6-doc libstdc++6-4.6-dbg lib64stdc++6-4.6-dbg
lib64mudflap0 libstdc++6-4.6-doc
g++ g++-4.4-multilib g++-4.6 g++-4.6-multilib g++-multilib gcc-4.4-multilib
gcc-4.6-multilib gcc-multilib lib64gcc1 lib64gomp1 lib64quadmath0
lib64stdc++6 libc6-amd64 libc6-dev-amd64 libstdc++6-4.6-dev
不过直接把gcc g++改为4.4就行了。不然早晚得改,代码基本没什么问题,关键你要找对修改的地方,还有各种依赖包要处理好
好了,看到结果了,编译完成了,嘎嘎
Installed file list: out/target/product/generic/installed-files.txt
Target system fs image: out/target/product/generic/obj/PACKAGING/systemimage_intermediates/system.img
Install system fs image: out/target/product/generic/system.img
Target ram disk: out/target/product/generic/ramdisk.img
Target userdata fs image: out/target/product/generic/userdata.img
thinkinbunny@thinkinbunny-360buy:~/桌面/droid4.03/droid$
g++ selected multilib '32' not installed
继续奋战吧,安装相应的工具吧:sudo apt-get install g++-4.4-multilib,现在正在make -j8在我的i5/4G机子里跑着。
出现java public 问题时,需要卸载系统自带的openjdk