編譯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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章