Android源码编译make的各类错误解决⽅案汇总
问题:
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官⽅地址下载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=.:$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH
error parse newexport PATH=$JAVA_HOME/bin:$JRE_HOME/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源码,按照提供⽅法先安装必要的⼯具。
以下是编译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<android::String8, android::sp<AaptDir> >’ 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<android::String8,
android::wp<android::AssetManager::SharedZip> >’ 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 " "
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 <getopt.h>' to list of includes:
#include <getopt.h>
>>>### 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<unsigned int, ShaderData*>’ 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<llvm::PointerUnion<clang::Stmt*, const clang::Type*> >::<anonymous enum>’ vs
‘llvm::PointerLikeTypeTraits<clang::ObjCInterfaceDecl*>::<anonymous enum>’ [-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<unsigned int,
android::renderscript::Font::CachedGlyphInfo*>’ 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 <stddef.h>' to list of includes as shown:
#include <climits>
#include <stddef.h>
#include <pixelflinger2/pixelflinger2_interface.h>
>>>### Fix 11 >>>>>
Error:
external/gtest/src/../include/gtest/gtest-param-test.h:287:58: note: ‘template<class Container> testing::internal::ParamGenerator<typename Container::value_type> 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
2)
vi external/gtest/include/gtest/internal/gtest-param-util.h
Add '#include <stddef.h>' to list of includes as shown:
#include <vector>
#include <cstddef>
#include <gtest/internal/gtest-port.h>
>>>### 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):在函数‘P
rintStackTrace’中:/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

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

发表评论