编译Android 2.3源码错误总结

虽然版本2.3很老了,但是这是在完全新的Ubuntu上面编译的,可以使我们更加熟练.

1.

host C: acp <= build/tools/acp/acp.c
<command-line>:0:0: warning: "_FORTIFY_SOURCE" redefined [enabled by default]
<built-in>:0:0: note: this is the location of the previous definition
In file included from /usr/include/stdlib.h:24:0,
                 from build/tools/acp/acp.c:11:
/usr/include/features.h:374:25: fatal error: sys/cdefs.h: No such file or directory
 #  include <sys/cdefs.h>
                         ^
compilation terminated.
make: *** [out/host/linux-x86/obj/EXECUTABLES/acp_intermediates/acp.o] Error 1

解决
sudo apt-get install libc6-dev-i386      //  Embedded GNU C Library: 32-bit development libraries for AMD64
sudo apt-get install libx32gcc-4.8-dev
sudo apt-get install lib32readline-gplv2-dev

libc6-dev 的解释      Embedded GNU C Library: Development Libraries and Header Files
gcc-multilib   的解释 GNU C compiler (multilib files)

2.
host C++: libhost <= build/libs/host/pseudolocalize.cpp
<command-line>:0:0: warning: "_FORTIFY_SOURCE" redefined [enabled by default]
<built-in>:0:0: note: this is the location of the previous definition
In file included from build/libs/host/include/host/pseudolocalize.h:4:0,
                 from build/libs/host/pseudolocalize.cpp:1:
/usr/include/c++/4.8/string:38:28: fatal error: bits/c++config.h: No such file or directory
 #include <bits/c++config.h>
                            ^
compilation terminated.
make: *** [out/host/linux-x86/obj/STATIC_LIBRARIES/libhost_intermediates/pseudolocalize.o] Error 1

解决:
sudo apt-get install gcc-4.8-multilib g++-4.8-multilib


3.
frameworks/base/tools/aapt/AaptAssets.cpp:1447:53:   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<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

解决办法:  frameworks/base/tools/aapt/Android.mk
       在第28行增加:
       LOCAL_CFLAGS += -Wno-format-y2k -fpermissive

4.
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

解决办法:在 frameworks/base/libs/utils/Android.mk
在第60行后面增加-fpermissive:       
       LOCAL_CFLAGS += -DLIBUTILS_NATIVE=1 $(TOOL_CFLAGS) -fpermissive

5.
make: *** [out/host/linux-x86/obj/EXECUTABLES/grxmlcompile_intermediates/grxmlcompile.o] 错误 1
    或者 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 ../..

6.
make: *** [out/host/linux-x86/obj/SHARED_LIBRARIES/libdvm_intermediates/native/dalvik_system_Zygote.o] Error 1
所以,这个问题只能修改源代码来解决
在dalvik/vm/native/dalvik_system_Zygote.c中间增加一个头文件定义#include <sys/resource.h>
        #include "Dalvik.h"
        #include "native/InternalNativePriv.h"
        #include <sys/resource.h>
 
 /usr/bin/ld: cannot find -lz
collect2: error: ld returned 1 exit status
make: *** [out/host/linux-x86/obj/EXECUTABLES/aapt_intermediates/aapt] Error 1

解决:
sudo apt-get install lib32z1-dev


7.
collect2: error: ld returned 1 exit status
make: *** [out/host/linux-x86/obj/EXECUTABLES/adb_intermediates/adb] Error

解决:
sudo apt-get install lib32ncurses5-dev


8.
make: *** [out/host/linux-x86/obj/STATIC_LIBRARIES/libext4_utils_intermediates/output_file.o] Error 1

解决:
由于系统的文件换了位置, 此时需要将  /usr/include/x86_64-linux-gnu/zconfig.h 拷贝到上级目录,此时编译才通过
将 zconfig.h 拷贝到 /usr/include/ 目录即可

9.

make: *** [out/host/linux-x86/obj/EXECUTABLES/obbtool_intermediates/Main.o] error 1
解决办法:系版本高,在配置环境的时候,gcc安装了高到版本,所以gcc版本太高导致,需要降低gcc版本级别。
ubuntu 32bit系统下安装gcc 4.4的最好方法是仅用以下两条命令,不需要其它命令,否则编译时可能会出错。
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 300
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 300
sudo apt-get install gcc-4.4
sudo apt-get install g++-4.4
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.4 350   
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.4 350


10.
g++: selected multilib '32' not installed
make: *** [out/host/linux-x86/obj/lib/libSR_Session.so] Error 1
make: *** Waiting for unfinished jobs....
target Prebuilt:  (out/target/product/generic/system/usr/share/bmd/RFFspeed_501.bmd)
g++: selected multilib '32' not installed
make: *** [out/host/linux-x86/obj/lib/libSR_Recognizer.so] Error 1

解决:
sudo apt-get install g++-4.4-multilib gcc-4.4-multilib


11.
BEGIN failed--compilation aborted at external/webkit/WebCore/dom/make_names.pl line 38.
make: *** [out/target/product/generic/obj/STATIC_LIBRARIES/libwebcore_intermediates/WebCore/HTMLNames.cpp] Error 2

解决办法:
sudo apt-get install libswitch-perl


12.
SDL init failure, reason is: No available video device  模拟器起不来

解决:

sudo apt-get install libsdl1.2debian:i386


下面是编译2.2的时候遇到的问题

13.

make: *** [out/host/linux-x86/obj/EXECUTABLES/localize_intermediates/localize] 错误 1

解决方法:
修改./framework/base/tools/localize/Android.mk文件
ifeq ($(HOST_OS),linux)
#LOCAL_LDLIBS += -lrt       把这行注释掉,改为下面一行。
LOCAL_LDLIBS += -lrt -lpthread
endif


14.

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


Description ResourcePath LocationType
Project 'AOSP' is missing required library: 'out/target/common/obj/JAVA_LIBRARIES/google-common_intermediates/javalib.jar'AOSP Build pathBuild Path Problem
  out/target/common/obj/APPS/CalendarProvider_intermediates/src/src/com/android/providers/calendar/EventLogTags.java
    out/target/common/obj/APPS/ContactsProvider_intermediates/src/src/com/android/providers/contacts/EventLogTags.java


make sdk打包SDK,有了sdk包就可以在IDE环境中开发安卓应用程序了
Package SDK Stubs: out/target/common/obj/PACKAGING/android_jar_intermediates/android.jar
Package SDK: out/host/linux-x86/sdk/android-sdk_eng.mec_linux-x86.zip
zImage文件默认位于源代码根目录下的子目录
/prebuilt/android-arm/kernel/kernel-qemu


编译安卓4.1报错

make: *** [out/target/product/generic/system/etc/apns-conf.xml] Error 127  安装下面的软件

mec@mecC:~/jellybean$ sudo apt-get  install libxml2-utils

猜你喜欢

转载自blog.csdn.net/jiyilanzhou/article/details/51675088