Android源码编译make的各类错误解决方案汇总

转载:http://www.voidcn.com/article/p-rjboindv-qx.html

问题:
You are attempting to build with the incorrect version of java.
Your version is: java version “1.6.0_22”.
The correct version is: Java SE 1.6.
查了一下现在已安装的java:
java -versionjava version "1.6.0_22"OpenJDK Runtime Environment (IcedTea6 1.10.4) (6b22-1.10.4-0ubuntu1~11.04.2)OpenJDK Client VM (build 20.0-b11, mixed mode, sharing)
解决办法如下:
1.从java官方地址 http://www.oracle.com/technetwork/java/javase/downloads/java-archive-downloads-javase6-419409.html下载Java SE Development Kit 6 Update 45文件。
2.移到/usr/lib/java目录下执行
chmod a+x jdk-6u45-linux-amd64.bin
sudo ./jdk-6u45-linux-amd64.bin
添加环境变量:
sudo gedit /etc/profile
在文件最后添加
#set java environment
export JAVA_HOME= /usr/lib/java/jdk1.6.0_45
export JRE_HOME= /usr/lib/java/jdk1.6.0_45/jre
export CLASSPATH=.: J A V A H O M E / l i b : JAVA_HOME/lib: JAVAHOME/lib:JRE_HOME/lib: C L A S S P A T H e x p o r t P A T H = CLASSPATH export PATH= CLASSPATHexportPATH=JAVA_HOME/bin: J R E H O M E / b i n : JRE_HOME/bin: JREHOME/bin:PATH
最后使环境变量生效:
source /etc/profile
Ubuntu系统默认安装并使用OpenJDK(usr/lib/jvm/),因此需要手动修改系统默认的JDK,

sudo update-alternatives --install /usr/bin/javac javac /usr/lib/java/jdk1.6.0_45/bin/javac 300

sudo update-alternatives --install /usr/bin/java java /usr/lib/java/jdk1.6.0_45/bin/java 300

sudo update-alternatives --config javac,再选择相应的Priority 300

sudo update-alternatives --config java,再选择相应的Priority 300

至此配置完成,输入java -version、javac或java检查是否配置成功。

首先,我们先安装一些常用的工具
curl: sudo apt-get install curl

git: sudo apt-get install git

g++: sudo apt-get install g++

然后,遇到缺什么就安装什么

/usr/bin/ld: cannot find -lz
host Executable: aapt (out/host/linux-x86/obj/EXECUTABLES/aapt_intermediates/aapt)
/usr/bin/ld: cannot find -lz
collect2: ld returned 1 exit status
make: *** [out/host/linux-x86/obj/EXECUTABLES/aapt_intermediates/aapt] Error 1
解决方法: sudo apt-get install zlib1g-dev sudo apt-get install lib64z1-dev
/bin/bash: bison: command not found
Yacc: aidl <= frameworks/base/tools/aidl/aidl_language_y.y
bison -d -o out/host/linux-x86/obj/EXECUTABLES/aidl_intermediates/aidl_language_y.cpp frameworks/base/tools/aidl/aidl_language_y.y
/bin/bash: bison: command not found
make: *** [out/host/linux-x86/obj/EXECUTABLES/aidl_intermediates/aidl_language_y.cpp] Error 127
解决方法:sudo apt-get install bison

/bin/bash: flex: command not found
out/host/linux-x86/obj/EXECUTABLES/aidl_intermediates/aidl_language_y.cpp: In function ‘int yyparse()’:
out/host/linux-x86/obj/EXECUTABLES/aidl_intermediates/aidl_language_y.cpp:1827: warning: deprecated conversion from string constant to ‘char*’
out/host/linux-x86/obj/EXECUTABLES/aidl_intermediates/aidl_language_y.cpp:1970: warning: deprecated conversion from string constant to ‘char*’
Lex: aidl <= frameworks/base/tools/aidl/aidl_language_l.l
/bin/bash: flex: command not found
make: *** [out/host/linux-x86/obj/EXECUTABLES/aidl_intermediates/aidl_language_l.cpp] Error 127
解决方法: sudo apt-get install flex

/usr/bin/ld: cannot find -lncurses
host Executable: adb (out/host/linux-x86/obj/EXECUTABLES/adb_intermediates/adb)
/usr/bin/ld: cannot find -lncurses
collect2: ld returned 1 exit status
make: *** [out/host/linux-x86/obj/EXECUTABLES/adb_intermediates/adb] Error 1
解决方法:sudo apt-get install libncurses5-dev或sudo apt-get install libncurses5-dev:i386

fatal error: GL/glx.h: No such file or directory
development/tools/emulator/opengl/host/libs/Translator/GLcommon/GLDispatch.cpp:22: fatal error: GL/glx.h: No such file or directory
compilation terminated.
make: *** [out/host/linux-x86/obj/STATIC_LIBRARIES/libGLcommon_intermediates/GLDispatch.o] Error 1
解决方法:sudo apt-get install libgl1-mesa-dev

sh: gperf: not found
target Generated: libwebcore <= external/webkit/Source/JavaScriptCore/create_regex_tables
Generating CSSPropertyNames.h <= CSSPropertyNames.in
sh: gperf: not found
calling gperf failed: 32512 at ./makeprop.pl line 140.
make: *** [out/target/product/generic/obj/STATIC_LIBRARIES/libwebcore_intermediates/Source/WebCore/css/CSSPropertyNames.h] Error 25
make: *** Deleting file `out/target/product/generic/obj/STATIC_LIBRARIES/libwebcore_intermediates/Source/WebCore/css/CSSPropertyNames.h’
解决方法:sudo apt-get install gperf

编译Android源码,按照installing-required-packages-ubuntu-1204提供方法先安装必要的工具。

以下是编译Android 4.0.3的常见错误,这些错误的解决办法收录自互联网。

Google group有个专门的Android Building组,有兴趣的可以加入。

有转载这里的也有添加的。

################# Fix 1 ##########################

Error:

frameworks/base/include/utils/KeyedVector.h:193:31: note: declarations in dependent base ‘android::KeyedVector’ are not found by unqualified lookup

frameworks/base/include/utils/KeyedVector.h:193:31: note: use ‘this->indexOfKey’ instead
make: *** [out/host/linux-x86/obj/EXECUTABLES/aapt_intermediates/AaptAssets.o] Error 1

Fix:
vi frameworks/base/tools/aapt/Android.mk

Add ‘-fpermissive’ to line 31:
LOCAL_CFLAGS += -Wno-format-y2k -fpermissive

################## Fix 2 ##########################

Error:
frameworks/base/include/utils/KeyedVector.h:193:31: error: ‘indexOfKey’ was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive]
frameworks/base/include/utils/KeyedVector.h:193:31: note: declarations in dependent base ‘android::KeyedVector’ are not found by unqualified lookup

frameworks/base/include/utils/KeyedVector.h:193:31: note: use ‘this->indexOfKey’ instead
make: *** [out/host/linux-x86/obj/STATIC_LIBRARIES/libutils_intermediates/AssetManager.o] Error 1

Fix:
vi frameworks/base/libs/utils/Android.mk

Add ‘-fpermissive’ to line 64:
LOCAL_CFLAGS += -DLIBUTILS_NATIVE=1 $(TOOL_CFLAGS) -fpermissive

################## Fix 3 ##########################

Error:
external/srec/tools/thirdparty/OpenFst/fst/lib/cache.h:136:11: note: use ‘this->SetState’ instead
make: *** [out/host/linux-x86/obj/EXECUTABLES/grxmlcompile_intermediates/grxmlcompile.o] Error 1

Fix:
cd external/srec
wget " https://github.com/CyanogenMod/android_external_srec/commit/4d7ae7b79eda47e489669fbbe1f91ec501d42fb2.diff"
patch -p1 < 4d7ae7b79eda47e489669fbbe1f91ec501d42fb2.diff
rm -f 4d7ae7b79eda47e489669fbbe1f91ec501d42fb2.diff
cd …/…

################## Fix 3.1 ##########################

Error:
host C++: obbtool <= frameworks/base/tools/obbtool/Main.cpp
host C: parseStringTest <= external/srec/tools/parseStringTest/parseStringTest.c
<命令行>:0:0: 错误: “_FORTIFY_SOURCE”重定义 [-Werror]
frameworks/base/tools/obbtool/Main.cpp:1:0: 附注: 这是先前定义的位置

make: *** [out/host/linux-x86/obj/EXECUTABLES/obbtool_intermediates/Main.o] 错误 1

Fix:
vi build/core/combo/HOST_linux-x86.mk line56
Add -U_FORTIFY_SOURCE
HOST_GLOBAL_CFLAGS += -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0

################## Fix 4 ##########################

Error:
development/tools/emulator/opengl/host/tools/emugen/main.cpp:79:9: error: ‘optind’ was not declared in this scope
development/tools/emulator/opengl/host/tools/emugen/main.cpp:92:45: error: ‘optind’ was not declared in this scope
make: *** [out/host/linux-x86/obj/EXECUTABLES/emugen_intermediates/main.o] Error 1

Fix:
vi development/tools/emulator/opengl/host/tools/emugen/main.cpp

Add ‘#include ’ to list of includes:
#include

################## Fix 5 ##########################

Error:
host C++: liboprofile_pp <= external/oprofile/libpp/arrange_profiles.cpp
In file included from external/oprofile/libpp/arrange_profiles.cpp:24:0:
external/oprofile/libpp/format_output.h:94:22: error: reference ‘counts’ cannot be declared ‘mutable’ [-fpermissive]
make: *** [out/host/linux-x86/obj/STATIC_LIBRARIES/liboprofile_pp_intermediates/arrange_profiles.o] Error 1

Fix:
vi external/oprofile/libpp/format_output.h

Remove ‘mutable’ from ‘mutable counts_t & counts;’ on line 94:
counts_t & counts;

################## Fix 6 ##########################

Error:
development/tools/emulator/opengl/shared/OpenglCodecCommon/GLSharedGroup.cpp:345:65: required from here

frameworks/base/include/utils/KeyedVector.h:193:31: error: ‘indexOfKey’ was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive]
frameworks/base/include/utils/KeyedVector.h:193:31: note: declarations in dependent base ‘android::KeyedVector’ are not found by unqualified lookup

frameworks/base/include/utils/KeyedVector.h:193:31: note: use ‘this->indexOfKey’ instead
make: *** [out/host/linux-x86/obj/STATIC_LIBRARIES/libOpenglCodecCommon_intermediates/GLSharedGroup.o] Error 1

Fix:
vi development/tools/emulator/opengl/Android.mk

Add ‘-fpermissive’ to line 25:
EMUGL_COMMON_CFLAGS := -DWITH_GLES2 -fpermissive

################## Fix 7 ##########################

Error:
/usr/bin/ld: note: ‘XInitThreads’ is defined in DSO /lib/libX11.so.6 so try adding it to the linker command line
/lib/libX11.so.6: could not read symbols: Invalid operation
collect2: error: ld returned 1 exit status
make: *** [out/host/linux-x86/obj/EXECUTABLES/emulator_renderer_intermediates/emulator_renderer] Error 1

Fix:
vi development/tools/emulator/opengl/host/renderer/Android.mk

Add new entry ‘LOCAL_LDLIBS += -lX11’ after line 6 as shown:
LOCAL_SRC_FILES := main.cpp
LOCAL_CFLAGS += -O0 -g
LOCAL_LDLIBS += -lX11

#ifeq ($(HOST_OS),windows)
#LOCAL_LDLIBS += -lws2_32

################## Fix 8 ##########################

Error:
external/llvm/include/llvm/ADT/PointerUnion.h:56:10: error: enumeral mismatch in conditional expression: ‘llvm::PointerLikeTypeTraits >::’ vs ‘llvm::PointerLikeTypeTraitsclang::ObjCInterfaceDecl*::’ [-Werror]
cc1plus: all warnings being treated as errors
make: *** [out/host/linux-x86/obj/EXECUTABLES/llvm-rs-cc_intermediates/slang_rs.o] Error 1

Fix:
vi frameworks/compile/slang/Android.mk

Remove ‘-Werror’ from line 22:
local_cflags_for_slang := -Wno-sign-promo -Wall -Wno-unused-parameter

################## Fix 9 ##########################

Error:
frameworks/base/libs/rs/rsFont.cpp:224:76: required from here

frameworks/base/include/utils/KeyedVector.h:193:31: error: ‘indexOfKey’ was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive]
frameworks/base/include/utils/KeyedVector.h:193:31: note: declarations in dependent base ‘android::KeyedVector’ are not found by unqualified lookup

frameworks/base/include/utils/KeyedVector.h:193:31: note: use ‘this->indexOfKey’ instead
make: *** [out/host/linux-x86/obj/STATIC_LIBRARIES/libRS_intermediates/rsFont.o] Error 1

Fix:
vi frameworks/base/libs/rs/Android.mk

Add ‘-fpermissive’ to line 183
LOCAL_CFLAGS += -Werror -Wall -Wno-unused-parameter -Wno-unused-variable -fpermissive

################## Fix 10 #########################

Error:
external/mesa3d/src/glsl/linker.cpp:1394:49: error: expected primary-expression before ‘,’ token

external/mesa3d/src/glsl/linker.cpp:1734:59: error: ‘offsetof’ was not declared in this scope
make: *** [out/host/linux-x86/obj/STATIC_LIBRARIES/libMesa_intermediates/src/glsl/linker.o] Error 1

Fix:
vi external/mesa3d/src/glsl/linker.cpp

Add ‘#include ’ to list of includes as shown:
#include
#include
#include

################## Fix 11 #########################

Error:
external/gtest/src/…/include/gtest/gtest-param-test.h:287:58: note: ‘template testing::internal::ParamGenerator testing::ValuesIn(const Container&)’ declared here, later in the translation unit
make: *** [out/host/linux-x86/obj/STATIC_LIBRARIES/libgtest_host_intermediates/gtest-all.o] Error 1

Two fixes required:
1)
vi external/gtest/src/Android.mk

Add ‘-fpermissive’ to lines 52 and 70 (both lines contain same info)
LOCAL_CFLAGS += -O0 -fpermissive

vi external/gtest/include/gtest/internal/gtest-param-util.h

Add ‘#include ’ to list of includes as shown:
#include
#include
#include

################## Fix 12 #########################
Error:
host Executable: test-librsloader (out/host/linux-x86/obj/EXECUTABLES/test-librsloader_intermediates/test-librsloader)
out/host/linux-x86/obj/STATIC_LIBRARIES/libLLVMSupport_intermediates/libLLVMSupport.a(Signals.o):在函数‘PrintStackTrace’中:
/home/crow/works/Android_src/external/llvm/lib/Support/Unix/Signals.inc:219:对‘dladdr’未定义的引用
/home/crow/works/Android_src/external/llvm/lib/Support/Unix/Signals.inc:231:对‘dladdr’未定义的引用
out/host/linux-x86/obj/STATIC_LIBRARIES/libLLVMSupport_intermediates/libLLVMSupport.a(Threading.o):在函数‘llvm::llvm_execute_on_thread(void ()(void), void*, unsigned int)’中:
/home/crow/works/Android_src/external/llvm/lib/Support/Threading.cpp:96:对‘pthread_create’未定义的引用
/home/crow/works/Android_src/external/llvm/lib/Support/Threading.cpp:100:对‘pthread_join’未定义的引用
/home/crow/works/Android_src/external/llvm/lib/Support/Threading.cpp:91:对‘pthread_attr_setstacksize’未定义的引用
out/host/linux-x86/obj/STATIC_LIBRARIES/libLLVMSupport_intermediates/libLLVMSupport.a(Mutex.o):在函数‘llvm::sys::MutexImpl::MutexImpl(bool)’中:
/home/crow/works/Android_src/external/llvm/lib/Support/Mutex.cpp:69:对‘pthread_mutexattr_init’未定义的引用
/home/crow/works/Android_src/external/llvm/lib/Support/Mutex.cpp:75:对‘pthread_mutexattr_settype’未定义的引用
/home/crow/works/Android_src/external/llvm/lib/Support/Mutex.cpp:80:对‘pthread_mutexattr_setpshared’未定义的引用
/home/crow/works/Android_src/external/llvm/lib/Support/Mutex.cpp:89:对‘pthread_mutexattr_destroy’未定义的引用
out/host/linux-x86/obj/STATIC_LIBRARIES/libLLVMSupport_intermediates/libLLVMSupport.a(Mutex.o):在函数‘llvm::sys::MutexImpl::tryacquire()’中:
/home/crow/works/Android_src/external/llvm/lib/Support/Mutex.cpp:143:对‘pthread_mutex_trylock’未定义的引用
collect2: 错误: ld 返回 1
make: *** [out/host/linux-x86/obj/EXECUTABLES/test-librsloader_intermediates/test-librsloader] 错误 1

Fix:

$vi external/llvm/llvm-host-build.mk

末尾加上:
LOCAL_LDLIBS := -lpthread -ldl

20150103补充:编译sdk时遇到不少的问题

build/core/main.mk:670: *** Module ‘AlarmProvider’ in PRODUCT_PACKAGES has nothing to install!。

Indeed there is no a module with name AlarmProvider in the source tree now.
To fix it, remove AlarmProvider from the product definition in the following files:
./build/target/product/large_emu_hw.mk:25: AlarmProvider
./build/target/product/generic_no_telephony.mk:24: AlarmProvider

只去掉generic_no_telephony.mk就可以过,但是不过的东西太多了。
我想是main.mk中的判断方法有误,因为同样一个文件,编译镜像就可以过,编译sdk就过不了。

在编译源代码的时候出现该错误
/usr/bin/ld.bfd.real: cannot find -lGL
/usr/bin/ld.bfd.real: cannot find -lX11
根据网上大多数的说法,以及官网的介绍。截至5月底,android对ubuntu12.04的编译平台的支持不是很推荐,有些库的兼容方面会有一些问题
这两个错误报的错其实就是说没有在库路径中找到libGL.so libX11.so
但是打开etc/ld.so.conf.d中查看64位的库路径下x86_64-linux-gnu.conf配置文件

Multiarch support

/lib/x86_64-linux-gnu
/usr/lib/x86_64-linux-gnu
该路径下是有libGL.so的,并且查看文件链接指向没有问题。但是编译起来还是有错。
后来再查看了一些资料,因为编译的时候还是用到了32BIT的libGL.so libX11.so库文件,编译的时候找的不是X86_64库文件配置,而是找的是I386库文件配置

Multiarch support

/lib/i386-linux-gnu
/usr/lib/i386-linux-gnu
/lib/i686-linux-gnu
/usr/lib/i686-linux-gnu
果然在I386目录下没有找到这两个文件
首先安装这两个库文件的32位版本:
$ sudo apt-get install libx11-dev:i386(libX11.so)
$ sudo apt-get installibgl1-mesa-glx:i386(libGL.so)
由于libGL.so系统默认没有进行库路径下的链接,还需要手动链接一下
$ sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1.2 /usr/lib/libGL.so

查找指定的符号在Android.mk中
find ./ -name Android.mk -exec grep -l {} ;

环境要求改变。
现在要求内存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.http://blog.csdn.net/mr_raptor/article/details/7394091
2.https://groups.google.com/forum/#!topic/android-building/kbhPdb6osms
收集和遇到的部分error,先记录如下,改天按照建立android及使用情景分类整理。以后遇到的在慢慢添加进来

1.编译错误:

“/usr/bin/ld:cannotfind -lz”

解决方法:

需要安装zlib-dev这个包,在线安装命令为:apt-getinstall zlib1g-dev

2.编译错误:

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]Error 1

解决方法:

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

修改以下语句

LOCAL_CFLAGS+= -DLIBUTILS_NATIVE=1 $(TOOL_CFLAGS)

LOCAL_CFLAGS+= -DLIBUTILS_NATIVE=1 $(TOOL_CFLAGS) –fpermissive

3.编译错误:

arm-eabi-gcc:error trying to exec ‘cc1’: execvp: No such file or directory
make:*** [out/target/product/generic/obj/lib/crtbegin_dynamic.o] Error 1

解决方法:

如果之前的依赖包都已经安装成功的话,此处应该是交叉编译工具权限的问题。这个问题只要在文章开头lunch时执行了赋予权限命令,就应该不会遇到了。

4.编译错误:

:0:0:error: “_FORTIFY_SOURCE” redefined [-Werror]
:0:0: note: this is the location of the previousdefinition
cc1plus: all warnings being treated as errors
make:*** [out/host/linux-x86/obj/EXECUTABLES/obbtool_intermediates/Main.o]Error 1

此处编译错误是由于ubuntu11.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

5.编译错误:

make:***[out/host/linux-x86/obj/EXECUTABLES/llvm-rs-cc_intermediates/slang_rs_export_foreach.o]错误1

解决办法:

找到frameworks/compile/slang/slang_rs_export_foreach.cpp:的249行,即:

llvm::StringRef ParamName = PVD->getName();

将本行注释掉即可继续编译。

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

后来发现了,原来是Ubuntu11.10里的gcc和g++版本太高了,于是执行下面的操作:

sudoapt-get install gcc-4.4

sudoapt-get install g+±4.4

sudorm -rf /usr/bin/gcc /usr/bin/g++

sudoln -s /usr/bin/gcc-4.4 /usr/bin/gcc

sudoln -s /usr/bin/g+±4.4 /usr/bin/g++

把默认的4.6版本换为了4.4,继续编译源码,又出现了另一个错误,大致提示为:

g++selected multilib ‘32’ not installed

继续奋战吧,安装相应的工具吧:sudoapt-get install g+±4.4-multilib,现在正在make-j8在我的i5/4G机子里跑着。

make:***[out/host/linux-x86/obj/STATIC_LIBRARIES/libMesa_intermediates/src/glsl/linker.o]Error 1

解决这个问题需要修改文件如下:

把"#include"添加到linker.cpp文件头部。

这样就可以编译完成了。

6.错误:

error:‘ptrdiff_t’ does not name a type
In file included fromexternal/gtest/src/…/include/gtest/gtest-param-test.h:157:0,
from external/gtest/src/…/include/gtest/gtest.h:69,
fromexternal/gtest/src/gtest_main.cc:32:
external/gtest/src/…/include/gtest/internal/gtest-param-util.h:122:11:error: ‘ptrdiff_t’ does not name a type
In file included fromexternal/gtest/src/…/include/gtest/gtest-param-test.h:157:0,
from external/gtest/src/…/include/gtest/gtest.h:69,
from external/gtest/src/…/src/gtest.cc:34,
fromexternal/gtest/src/gtest-all.cc:36:
external/gtest/src/…/include/gtest/internal/gtest-param-util.h:122:11:error: ‘ptrdiff_t’ does not name a type
In file included fromexternal/gtest/src/gtest-all.cc:38:0:
解决方法:
$viexternal/gtest/src/…/include/gtest/internal/gtest-param-util.h
#include
7.错误:

undefinedreference to pthread_mutexattr_destroy' host C++: libgtest_host<= external/gtest/src/gtest-all.cc true host C++:libgtest_main_host <=external/gtest/src/gtest_main.cc out/host/linux-x86/obj/STATIC_LIBRARIES/libLLVMSupport_intermediates/libLLVMSupport.a(Signals.o):In functionPrintStackTrace’:
/home/aa/project/android4.0.1/external/llvm/lib/Support/Unix/Signals.inc:219:undefined reference todladdr' /home/aa/project/android4.0.1/external/llvm/lib/Support/Unix/Signals.inc:231:undefined reference todladdr’
out/host/linux-x86/obj/STATIC_LIBRARIES/libLLVMSupport_intermediates/libLLVMSupport.a(Threading.o):In function llvm::llvm_execute_on_thread(void (*)(void*), void*,unsignedint)': /home/aa/project/android4.0.1/external/llvm/lib/Support/Threading.cpp:96:undefined reference topthread_create’
/home/aa/project/android4.0.1/external/llvm/lib/Support/Threading.cpp:91:undefined reference topthread_attr_setstacksize' /home/aa/project/android4.0.1/external/llvm/lib/Support/Threading.cpp:100:undefined reference topthread_join’
out/host/linux-x86/obj/STATIC_LIBRARIES/libLLVMSupport_intermediates/libLLVMSupport.a(Mutex.o):In functionMutexImpl': /home/aa/project/android4.0.1/external/llvm/lib/Support/Mutex.cpp:69:undefined reference topthread_mutexattr_init’
/home/aa/project/android4.0.1/external/llvm/lib/Support/Mutex.cpp:75:undefined reference topthread_mutexattr_settype' /home/aa/project/android4.0.1/external/llvm/lib/Support/Mutex.cpp:80:undefined reference topthread_mutexattr_setpshared’
/home/aa/project/android4.0.1/external/llvm/lib/Support/Mutex.cpp:89:undefined reference topthread_mutexattr_destroy' out/host/linux-x86/obj/STATIC_LIBRARIES/libLLVMSupport_intermediates/libLLVMSupport.a(Mutex.o):In functionllvm::sys::MutexImpl::tryacquire()’:
/home/aa/project/android4.0.1/external/llvm/lib/Support/Mutex.cpp:143:undefined reference to `pthread_mutex_trylock’
collect2: ldreturned 1 exit status
make: ***[out/host/linux-x86/obj/EXECUTABLES/test-librsloader_intermediates/test-librsloader]Error 1
make: *** Waiting for unfinished jobs…
解决方法:
$viexternal/llvm/llvm-host-build.mk
LOCAL_LDLIBS := -lpthread-ldl
下面这个解决方法没成功,会有新的错误:errorsagain :can’t find threads.h file or dir.
$ viexternal/llvm/lib/Support/Android.mk
LOCAL_C_INCLUDES +=system/core/include/cutils
LOCAL_SHARED_LIBRARIES := libcutil
$vi external/llvm/lib/Support/Mutex.cpp
#include
$vi external/llvm/lib/Support/Threading.cpp
#include
8错误:

error:variable ‘ParamName’ set but not used[-Werror=unused-but-set-variable]
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 beingtreated as errors
解决方法:
$vi frameworks/compile/slang/Android.mk
#local_cflags_for_slang :=-Wno-sign-promo -Wall -Wno-unused-parameter-Werror
local_cflags_for_slang := -Wno-sign-promo -Wall-Wno-unused-parameter

9.错误:

一、环境设置

wayne@wayne-pc:~/Android/source s o u r c e b u i l d / e n v s e t u p . s h i n c l u d i n g d e v i c e / h t c / p a s s i o n / v e n d o r s e t u p . s h i n c l u d i n g d e v i c e / s a m s u n g / c r e s p o / v e n d o r s e t u p . s h w a y n e @ w a y n e − p c :   / A n d r o i d / s o u r c e source build/envsetup.sh includingdevice/htc/passion/vendorsetup.sh includingdevice/samsung/crespo/vendorsetup.sh wayne@wayne-pc:~/Android/source sourcebuild/envsetup.shincludingdevice/htc/passion/vendorsetup.shincludingdevice/samsung/crespo/vendorsetup.shwayne@waynepc: /Android/sourcelunch full-eng

在lunch时,如果提示permissiondenied权限不够的话,需要在源码根目录下执行,赋予目录下所有文件权限

wayne@wayne-pc:~/Android/source$sudo chmod -R 777 *

这时候会lunch指令会打印出如下所示文段:

============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=2.3.3
TARGET_PRODUCT=full
TARGET_BUILD_VARIANT=eng
TARGET_SIMULATOR=false
TARGET_BUILD_TYPE=release
TARGET_BUILD_APPS=
TARGET_ARCH=arm
HOST_ARCH=x86
HOST_OS=linux
HOST_BUILD_TYPE=release
BUILD_ID=GRI40

一、开始编译

编译过程可能会出现许多错误而中止,在此wayne将会把所有遇到的问题以及解决方法一一贴出来,以供以后参考。

10.错误:

wayne@wayne-pc:~/Android/source$make-j2

PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=2.3.3
TARGET_PRODUCT=full
TARGET_BUILD_VARIANT=eng
TARGET_SIMULATOR=false
TARGET_BUILD_TYPE=release
TARGET_BUILD_APPS=
TARGET_ARCH=arm
HOST_ARCH=x86
HOST_OS=linux
HOST_BUILD_TYPE=release
BUILD_ID=GRI40

Checkingbuild tools versions…
build/core/main.mk:76:************************************************************
build/core/main.mk:77:You are attempting to build on a 32-bitsystem.
build/core/main.mk:78: Only 64-bit build environments aresupported beyond froyo/2.2.
build/core/main.mk:79:************************************************************
build/core/main.mk:80:*** stop。停止。

解决方法:cd到源码根目录,执行:

$gedit build/core/main.mk

找到

ifneq(64, ( f i n d s t r i n g 64 , (findstring 64, (findstring64,(build_arch)))

将其修改为

ifneq(i686, ( f i n d s t r i n g i 686 , (findstring i686, (findstringi686,(build_arch)))

然后依次修改以下四个make文件:

external/clearsilver/cgi/Android.mk
external/clearsilver/java-jni/Android.mk
external/clearsilver/util/Android.mk
external/clearsilver/cs/Android.mk

将其中的

LOCAL_CFLAGS+= -m64
LOCAL_LDFLAGS += -m64

修改为

LOCAL_CFLAGS+= -m32
LOCAL_LDFLAGS += -m32

11.错误:

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]Error 1

解决方法:

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

修改以下语句

LOCAL_CFLAGS+= -DLIBUTILS_NATIVE=1 $(TOOL_CFLAGS)

LOCAL_CFLAGS+= -DLIBUTILS_NATIVE=1 $(TOOL_CFLAGS) –fpermissive

12.错误:

arm-eabi-gcc:error trying to exec ‘cc1’: execvp: No such file or directory
make:*** [out/target/product/generic/obj/lib/crtbegin_dynamic.o] Error 1

如果之前的依赖包都已经安装成功的话,此处应该是交叉编译工具权限的问题。这个问题只要在文章开头lunch时执行了赋予权限命令,就应该不会遇到了。

13.错误:

:0:0:error: “_FORTIFY_SOURCE” redefined [-Werror]
:0:0: note: this is the location of the previousdefinition
cc1plus: all warnings being treated as errors
make:*** [out/host/linux-x86/obj/EXECUTABLES/obbtool_intermediates/Main.o]Error 1

此处编译错误是由于ubuntu11.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

编译时还有可能出现类似的错误,根据错误提示的关键词比如g++错误、jre错误等,都是些细节问题,比较好解决。

经过两小时左右的等待后,终于顺利完成。编译成功后会生成system.img等镜像文件,下面是编译完成提示:

Targetsystem fs image:out/target/product/generic/obj/PACKAGING/systemimage_intermediates/system.img
Installsystem fs image: out/target/product/generic/system.img
Installedfile list: out/target/product/generic/installed-files.txt

三、启动所编译的系统

编译完之后会在out/target/product/generic目录下生成system.imgramdisk.img userdata.img三个镜像文件。

在启动模拟器之前,需要先为模拟器系统设置环境变量,执行gedit~/.bashrc,新增环境变量如下:

exportANDROID_PRODUCT_OUT=~/Android/source/out/target/product/generic
ANDROID_PRODUCT_OUT_BIN=~/Android/source/out/host/linux-x86/bin
exportPATH= P A T H : {PATH}: PATH:{ANDROID_PRODUCT_OUT_BIN}?{ANDROID_PRODUCT_OUT};

最后,同步这些变化并启动模拟器:

$source ~/.bashrc
$ cd~/Android/source/out/target/product/generic
$ emulator -systemsystem.img -data userdata.img -ramdisk ramdisk.img

加载上我们所编译出来的系统文件,终于出现了期待已久的模拟器:

ubuntu编译Android出现的若干错误及解决方法

刚下好android源码后马上编译会发现有各种各样的错误,原因是有些依赖包没有装。

为了避免出现以下我遇到的错误,请先安装jdk1.5,必须是jdk1.5,不然肯定编译不过的。

然后,在检查以下有没有安装以下依赖包:

sudoapt-get install bison libc6-dev-amd64 g+±multilib zlib1g-devlib64z1-dev flex libncurses5-dev libx11-dev gperf

下面是我遇到的错误及解决方法:

/bin/bash:bison:找不到命令
Checkingbuild toolsversions…


Youare attempting to build with the incorrect version
of java.

Yourversion is: /bin/bash: java:找不到命令.
Thecorrect version is: 1.6.

Pleasefollow the machine setup instructions at

http://source.android.com/source/download.html


build/core/main.mk:114:*** stop。停止。

解决方法:
sudoapt-get install bison

Install:out/host/linux-x86/framework/droiddoc.jar
target Generated:libclearsilver-jni <=out/host/common/obj/JAVA_LIBRARIES/clearsilver_intermediates/javalib.jar
hostC: libclearsilver-jni <=external/clearsilver/java-jni/j_neo_util.c
In file included from/usr/include/features.h:378,
from /usr/include/string.h:26,
fromexternal/clearsilver/java-jni/j_neo_util.c:1:
/usr/include/gnu/stubs.h:9:27:error: gnu/stubs-64.h: 没有那个文件或目录
make:***[out/host/linux-x86/obj/SHARED_LIBRARIES/libclearsilver-jni_intermediates/j_neo_util.o]错误1

解决方法:
sudoapt-get install libc6-dev-amd64

http://www.poemcode.net/2010/07/android-stubs-64/

hostSharedLib: libneo_util(out/host/linux-x86/obj/lib/libneo_util.so)
/usr/bin/ld: skippingincompatible /usr/lib/gcc/i486-linux-gnu/4.4.3/libstdc++.so whensearching for -lstdc++
/usr/bin/ld: skipping incompatible/usr/lib/gcc/i486-linux-gnu/4.4.3/libstdc++.a when searching for-lstdc++
/usr/bin/ld: skipping incompatible/usr/lib/gcc/i486-linux-gnu/4.4.3/libstdc++.so when searching for-lstdc++
/usr/bin/ld: skipping incompatible/usr/lib/gcc/i486-linux-gnu/4.4.3/libstdc++.a when searching for-lstdc++
/usr/bin/ld: cannot find -lstdc++
collect2: ldreturned 1 exit status
make: ***[out/host/linux-x86/obj/lib/libneo_util.so] 错误1

解决方法:
sudoapt-get install g+±multilib

external/clearsilver/cgi/cgi.c:22:18:error: zlib.h:没有那个文件或目录
external/clearsilver/cgi/cgi.c:In function ‘cgi_compress’:
external/clearsilver/cgi/cgi.c:885:error: ‘z_stream’ undeclared (first use in thisfunction)
external/clearsilver/cgi/cgi.c:885: error: (Eachundeclared identifier is reported onlyonce
external/clearsilver/cgi/cgi.c:885: error: for each functionit appears in.)
external/clearsilver/cgi/cgi.c:885: error:expected ‘;’ before ‘stream’
external/clearsilver/cgi/cgi.c:888:error: ‘stream’ undeclared (first use in thisfunction)
external/clearsilver/cgi/cgi.c:888: error: ‘Bytef’undeclared (first use in thisfunction)
external/clearsilver/cgi/cgi.c:888: error: expectedexpression before ‘)’ token
external/clearsilver/cgi/cgi.c:889:error: ‘uInt’ undeclared (first use in thisfunction)
external/clearsilver/cgi/cgi.c:889: error: expected ‘;’before ‘str’
external/clearsilver/cgi/cgi.c:890: error:expected expression before ‘)’token
external/clearsilver/cgi/cgi.c:892: error: ‘uLong’undeclared (first use in thisfunction)
external/clearsilver/cgi/cgi.c:892: error: expected ‘)’before ‘stream’
external/clearsilver/cgi/cgi.c:895: error:‘alloc_func’ undeclared (first use in thisfunction)
external/clearsilver/cgi/cgi.c:895: error: expected ‘;’before numeric constant
external/clearsilver/cgi/cgi.c:896: error:‘free_func’ undeclared (first use in thisfunction)
external/clearsilver/cgi/cgi.c:896: error: expected ‘;’before numeric constant
external/clearsilver/cgi/cgi.c:897: error:‘voidpf’ undeclared (first use in thisfunction)
external/clearsilver/cgi/cgi.c:897: error: expected ‘;’before numeric constant
external/clearsilver/cgi/cgi.c:900: error:‘Z_DEFAULT_COMPRESSION’ undeclared (first use in thisfunction)
external/clearsilver/cgi/cgi.c:900: error: ‘Z_DEFLATED’undeclared (first use in thisfunction)
external/clearsilver/cgi/cgi.c:900: error: ‘MAX_WBITS’undeclared (first use in thisfunction)
external/clearsilver/cgi/cgi.c:900: error:‘Z_DEFAULT_STRATEGY’ undeclared (first use in thisfunction)
external/clearsilver/cgi/cgi.c:901: error: ‘Z_OK’undeclared (first use in thisfunction)
external/clearsilver/cgi/cgi.c:904: error: ‘Z_FINISH’undeclared (first use in thisfunction)
external/clearsilver/cgi/cgi.c:905: error:‘Z_STREAM_END’ undeclared (first use in thisfunction)
external/clearsilver/cgi/cgi.c: In function‘cgi_output’:
external/clearsilver/cgi/cgi.c:1200: error:‘Z_NULL’ undeclared (first use in thisfunction)
external/clearsilver/cgi/cgi.c:1201: error: expected ‘)’before ‘Bytef’
external/clearsilver/cgi/cgi.c:1201: warning:cast from pointer to integer of differentsize
external/clearsilver/cgi/cgi.c:1218: error: ‘Z_DEFLATED’undeclared (first use in this function)
make: ***[out/host/linux-x86/obj/SHARED_LIBRARIES/libneo_cgi_intermediates/cgi.o]错误1

解决方法:
sudoapt-get install zlib1g-dev

hostSharedLib: libneo_cgi(out/host/linux-x86/obj/lib/libneo_cgi.so)
/usr/bin/ld: skippingincompatible /usr/lib/gcc/i486-linux-gnu/4.4.3/…/…/…/libz.so whensearching for -lz
/usr/bin/ld: skipping incompatible/usr/lib/gcc/i486-linux-gnu/4.4.3/…/…/…/libz.a when searching for-lz
/usr/bin/ld: skipping incompatible /usr/lib/libz.so whensearching for -lz
/usr/bin/ld: skipping incompatible/usr/lib/libz.a when searching for -lz
/usr/bin/ld: cannot find-lz
collect2: ld returned 1 exit status
make: ***[out/host/linux-x86/obj/lib/libneo_cgi.so] 错误1

解决方法:
sudoapt-get install lib64z1-dev

out/host/linux-x86/obj/EXECUTABLES/aidl_intermediates/aidl_language_y.cpp:In function ‘intyyparse()’:
out/host/linux-x86/obj/EXECUTABLES/aidl_intermediates/aidl_language_y.cpp:1827⚠️ deprecated conversion from string constant to‘char*’
out/host/linux-x86/obj/EXECUTABLES/aidl_intermediates/aidl_language_y.cpp:1970⚠️ deprecated conversion from string constant to ‘char*’
Lex:aidl <= frameworks/base/tools/aidl/aidl_language_l.l
/bin/bash:flex:找不到命令
make:***[out/host/linux-x86/obj/EXECUTABLES/aidl_intermediates/aidl_language_l.cpp]错误127

解决方法:
sudoapt-get install flex

Docsdroiddoc: out/target/common/docs/api-stubs
Could not load’clearsilver-jni’
java.library.path = out/host/linux-x86/lib
make:*** [out/target/common/docs/api-stubs-timestamp] 错误45

解决方法:
安装jdk1.5

hostExecutable: adb(out/host/linux-x86/obj/EXECUTABLES/adb_intermediates/adb)
/usr/bin/ld:cannot find -lncurses
collect2: ld returned 1 exit status
make:*** [out/host/linux-x86/obj/EXECUTABLES/adb_intermediates/adb] 错误1

解决方法:
sudoapt-get install libncurses5-dev

hostC: emulator <= external/qemu/android/main.c
In file includedfromexternal/qemu/android/main.c:30:
prebuilt/linux-x86/sdl/include/SDL/SDL_syswm.h:55:22:error: X11/Xlib.h:没有那个文件或目录
prebuilt/linux-x86/sdl/include/SDL/SDL_syswm.h:56:23:error: X11/Xatom.h: 没有那个文件或目录
Infile included fromexternal/qemu/android/main.c:30:
prebuilt/linux-x86/sdl/include/SDL/SDL_syswm.h:73:error: expected specifier-qualifier-list before‘XEvent’
prebuilt/linux-x86/sdl/include/SDL/SDL_syswm.h:86:error: expected specifier-qualifier-list before‘Display’
external/qemu/android/main.c: In function‘main’:
external/qemu/android/main.c:1281: warning: implicitdeclaration of function ‘audio_check_backend_name’
make: ***[out/host/linux-x86/obj/EXECUTABLES/emulator_intermediates/android/main.o]错误1

解决方法:
sudoapt-get install libx11-dev

GeneratingCSSPropertyNames.h <= CSSPropertyNames.in
sh: gperf: notfound
calling gperf failed: 32512 at ./makeprop.pl line 96.
make:***[out/target/product/generic/obj/STATIC_LIBRARIES/libwebcore_intermediates/WebCore/css/CSSPropertyNames.h]错误25
make:***正在删除文件“out/target/product/generic/obj/STATIC_LIBRARIES/libwebcore_intermediates/WebCore/css/CSSPropertyNames.h”

解决方法:
sudoapt-get install gperf

1、host Java: jsr305lib (out/host/common/obj/JAVA_LIBRARIES/jsr305lib_intermediates/classes)
/bin/bash: jar: command not found
make: *** [out/host/common/obj/JAVA_LIBRARIES/jsr305lib_intermediates/javalib.jar] Error 127
fix:
cd /usr/bin
必须先进入/usr/bin,下同
sudo ln -s -f /usr/lib/jvm/jdk1.6.0_30/bin/jar
我的jdk是安装在/usr/lib/jvm/jdk1.6.0_30/目录下的
如果提示javah:commond not found,于是照葫芦画瓢,输入命令
cd /usr/bin
ln -s -f /usr/lib/jvm/jdk1.6.0_30/bin/javah
2、
A:
Docs droiddoc: out/target/common/docs/doc-comment-check
/bin/bash: line 2: javadoc: command not found
make: *** [out/target/common/docs/doc-comment-check-timestamp] Error 45
root@shepherd-VPCS134GX:/home/shepherd/Android# sudo ln -s -f /usr/lib/jvm/jdk1.6.0_34/bin/javadoc /bin/javadoc
3、
Q:external/srec/tools/thirdparty/OpenFst/fst/lib/cache.h:136:11: note: declarations in dependent base ‘fst::VectorFstBaseImpl > >’ are not found by unqualified lookup
external/srec/tools/thirdparty/OpenFst/fst/lib/cache.h:136:11: note: use ‘this->SetState’ instead
make: *** [out/host/linux-x86/obj/EXECUTABLES/grxmlcompile_intermediates/grxmlcompile.o] Error 1
4、
Q:frameworks/base/tools/obbtool/Main.cpp:1:0: note: this is the location of the previous definition
cc1plus: all warnings being treated as errors
make: *** [out/host/linux-x86/obj/EXECUTABLES/obbtool_intermediates/Main.o] Error 1
fix:
将以下语句(line56)
HOST_GLOBAL_CFLAGS += -D_FORTIFY_SOURCE=0
修改为
HOST_GLOBAL_CFLAGS += -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0
5、
Q:make: *** [out/host/linux-x86/obj/STATIC_LIBRARIES/libgtest_host_intermediates/gtest-all.o] Error 1

external/gtest/include/gtest/internal/gtest-param-util.h
add
#include
6、
Q:selected multilib ‘32’ not installed
g++: make: *** [out/host/linux-x86/obj/EXECUTABLES/aprotoc_intermediates/aprotoc] Error 1
make: *** Waiting for unfinished jobs…
make: *** [out/host/linux-x86/obj/lib/libext2_com_err.so] Error 1
selected multilib ‘32’ not installed
g++: selected multilib ‘32’ not installed
make: *** [out/host/linux-x86/obj/lib/libext2_uuid.so] Error 1
make: *** [out/host/linux-x86/obj/lib/libext2_e2p.so] Error 1
7、
总是显示:
/device/ti/panda#./usbboot bootloader.bin
using built-in 2ndstage.bin
waiting for OMAP44xx device…
google后发现是这个usbboot太老,不能识别pandaboard ES的板子的ID。使用新的usbboot就OK了 ?
See here:
https://groups.google.com/forum/?fromgroups=#!topic/pandaboard/lsojoXPF3YI
https://github.com/swetland/omap4boot
Other Issue:
串口出现:
MSV=00000000
*** SIGNATURE VERIFICATION FAILED ***
把usbboot的源码里面的about.c里的
#define WITH_SIGNATURE_CHECK 1
改为:
#define WITH_SIGNATURE_CHECK 0
重新编译即可。
8、
一直在adnroid字样logo中无法进入界面
下载imgtec-panda-iml74k-cfb7bdad.tar.gz(本人的资源库中有得下)
tar xvf imgtec-panda-iml74k-cfb7bdad.tar.gz
cd imgtec-panda-iml74k-cfb7bdad
cp imgtec-panda-iml74k-cfb7bdad.sh android/ICS/(这是用户具体的ICS系统目录下)
./imgtec-panda-iml74k-cfb7bdad.sh
9、
这个错误是由分配的空间太小导致的。
解决方法:
打开device/odm/Mary/BoardConfig.mk
扩大BOARD_*_PARTITION_SIZE的大小,如:
  BOARD_SYSTEMIMAGE_PARTITION_SIZE := 251658240 #0x0F000000 #167772160 # 0x0A000000
10、
=== error: do_inode_allocate_extents: Failed to allocate blocks ===

One way to workaround this is to increase the system image size.
Please see BOARD_*_PARTITION_SIZE variables in device//$(TARGET_PRODUCT)/BoardConfig.mk in your workspace.


machine android.googlesource.com login git-ShepherdSandra49.gmail.com password 1/6lVVhJay8pTnULfp9kmd4RlBL3VP6-HG56p0aDRCJ2Q
machine android-review.googlesource.com login git-ShepherdSandra49.gmail.com password 1/6lVVhJay8pTnULfp9kmd4RlBL3VP6-HG56p0aDRCJ2Q

chage the revision to “android”/“linaro-master”
11、
Fetching projects: 100% (294/294), done.
Traceback (most recent call last):
File “/home/helei/workspace/android_source/.repo/repo/main.py”, line 385, in
_Main(sys.argv[1:])
File “/home/helei/workspace/android_source/.repo/repo/main.py”, line 365, in _Main
result = repo._Run(argv) or 0
File “/home/helei/workspace/android_source/.repo/repo/main.py”, line 137, in _Run
result = cmd.Execute(copts, cargs)
File “/home/helei/workspace/android_source/.repo/repo/subcmds/sync.py”, line 469, in Execute
project.Sync_LocalHalf(syncbuf)
File “/home/helei/workspace/android_source/.repo/repo/project.py”, line 1049, in Sync_LocalHalf
lost = self._revlist(not_rev(revid), HEAD)
File “/home/helei/workspace/android_source/.repo/repo/project.py”, line 1791, in _revlist
return self.work_git.rev_list(*a, **kw)
File “/home/helei/workspace/android_source/.repo/repo/project.py”, line 1936, in rev_list
p.stderr))
error.GitError: platform/abi/cpp rev-list (’^e9832499ad6834be10fd651b80871630ca7206c6’, ‘HEAD’, ‘–’): fatal: bad object e9832499ad6834be10fd651b80871630ca7206c6
解决办法是删除以前生成的所有源码目录,注意除.repo以外,这个目录中包含你从源码树上同步下来的所有源码,之前删除的文件只是源码树中由脚本自动提取的对应分支的源码。

make: *** [out/target/common/obj/APPS/Calculator_intermediates/classes-full-debug.jar] 错误 41
make: *** 正在等待未完成的任务…
packages/apps/Camera/src/com/android/camera/BitmapManager.java:19: 无法访问 android.content.ContentResolver
错误的类文件: android/content/ContentResolver.class(android/content:ContentResolver.class)
无法访问文件: corrupted zip file
请删除该文件或确保该文件位于正确的类路径子目录中。
import android.content.ContentResolver;
^
make: *** [out/target/common/obj/APPS/Camera_intermediates/classes-full-debug.jar] 错误 41
development/samples/ApiDemos/src/com/example/android/apis/animation/Rotate3dAnimation.java:19: 无法访问 android.view.animation.Animation
错误的类文件: android/view/animation/Animation.class(android/view/animation:Animation.class)
无法访问文件: corrupted zip file
请删除该文件或确保该文件位于正确的类路径子目录中。
import android.view.animation.Animation;
^
make: *** [out/target/common/obj/APPS/ApiDemos_intermediates/classes-full-debug.jar] 错误 41
packages/apps/DeskClock/src/com/android/alarmclock/AnalogAppWidgetProvider.java:22: 无法访问 android.app.PendingIntent
错误的类文件: android/app/PendingIntent.class(android/app:PendingIntent.class)
无法访问文件: corrupted zip file
请删除该文件或确保该文件位于正确的类路径子目录中。
import android.app.PendingIntent;
^
make: *** [out/target/common/obj/APPS/DeskClock_intermediates/classes-full-debug.jar] 错误 41
解决方法
以上错误是由于编译系统文件时没安装所需要包,以下是整个过程中所需的所有包:
$sudo apt-get install git-core gnupg gperf libsdl-dev libesd0-dev
$sudo apt-get install libwxgtk2.6-dev zip curl minicom tftpd
$sudo apt-get install uboot-mkimage libx11-dev libncurses-dev
s u d o a p t − g e t i n s t a l l e x p e c t b i s o n b u i l d − e s s e n t i a l f l e x z l i b 1 g − d e v < s p a n s t y l e = " f o n t − s i z e : 18 p x ; " > 之 后 输 入 如 下 命 令 来 清 除 已 编 译 的 : sudo apt-get install expect bison build-essential flex zlib1g-dev <span style="font-size: 18px;">之后输入如下命令来清除已编译的: sudoaptgetinstallexpectbisonbuildessentialflexzlib1gdev<spanstyle="fontsize:18px;"> make clobber
接着重新编译就可以了(没办法,只能重新编译-_-)。

参考:
编译android源码时You are attempting to build with the incorrect version of java.
Ubuntu安装JDK及环境变量配置
Android源码编译make的错误处理
Ubuntu12.10编译Android 4.0.3的常见错误
Android 编译错误总结及收集
编译Android Source时碰到的问题
在制作android系统文件时出错

你可能感兴趣的:(linux学习)