在ubuntu 14.04 编译android 2.3.1 错误解决办法

首先必须降低gcc版本:

sudo apt-get install gcc-4.4
sudo apt-get install g++-4.4
sudo rm -rf /usr/bin/gcc /usr/bin/g++
sudo ln -s /usr/bin/gcc-4.4 /usr/bin/gcc
sudo ln -s /usr/bin/g++-4.4 /usr/bin/g++

 

 

################ 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

 

问题三
external/srec/tools/thirdparty/OpenFst/fst/lib/cache.h:132:26: note: declarations in dependent base 'fst::VectorFstBaseImpl<fst::CacheState<fst::GallicArc<fst::StdArc, (fst::StringType)0u> > >' are not found by unqualified lookup
external/srec/tools/thirdparty/OpenFst/fst/lib/cache.h:132:26: note: use 'this->SetState' instead
external/srec/tools/thirdparty/OpenFst/fst/lib/cache.h:136:61: error: 'SetState' was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive]
SetState(cache_first_state_id_, cache_first_state_);

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

解决办法:
cd external/srec
wget "https://github.com/CyanogenMod/android_external_srec/commit/4d7ae7b79eda47e489669fbbe1f91ec501d42fb2.diff"
patch -p1 < 4d7ae7b79eda47e489669fbbe1f91ec501d42fb2.diff
rm -f 4d7ae7b79eda47e489669fbbe1f91ec501d42fb2.diff
cd ../..

此方法是我找的别人对于4.0版本源码问题的解决方法,我用在了2.3上,没有出现问题

dalvik_system_Zygote.c:191:19: error: storage size of 'rlim' isn't known

解决办法
添加头文件#include <sys/resource.h>到以下文件
dalvik/vm/native/dalvik_system_Zygote.cpp 

 

<command-line>:0:0: error: "_FORTIFY_SOURCE" redefined [-Werror]

解决办法
gcc
g++版本太高了
sudo apt-get install gcc-4.4
sudo apt-get install g++-4.4
sudo rm -rf /usr/bin/gcc /usr/bin/g++
sudo ln -s /usr/bin/gcc-4.4 /usr/bin/gcc
sudo ln -s /usr/bin/g++-4.4 /usr/bin/g++

 

Can't locate Switch.pm in @INC (you may need to install the Switch module) (@INC

 contains: external/webkit/WebCore/bindings/scripts /etc/perl /usr/local/lib/per

l/5.18.2 /usr/local/share/perl/5.18.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/p

erl/5.18 /usr/share/perl/5.18 /usr/local/lib/site_perl .) at external/webkit/Web

Core/dom/make_names.pl line 38.

BEGIN failed--compilation aborted at external/webkit/WebCore/dom/make_names.pl l

ine 38.

Can't locate Switch.pm in @INC (you may need to install the Switch module) (@INC

 contains: external/webkit/WebCore/bindings/scripts /etc/perl /usr/local/lib/per

l/5.18.2 /usr/local/share/perl/5.18.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/p

erl/5.18 /usr/share/perl/5.18 /usr/local/lib/site_perl .) at external/webkit/Web

Core/dom/make_names.pl line 38.

BEGIN failed--compilation aborted at external/webkit/WebCore/dom/make_names.pl l

ine 38.

 

解决方法是安装perlswitch库:

[plain] view plaincopy

  1. sudo apt-get install libswitch-perl  
posted on 2015-01-28 18:47  baizx  阅读(2406)  评论(0编辑  收藏  举报