2012年7月28日 星期六

解決DMA-210L開發平台在Ubuntu 12.04 LTS下編譯Android 2.3.4出現的問題


近日因緣際會測試到長高科技的 ARM Cortex A8 DMA-210L開發平台,由於該平台目前使用的是Android 2.3.4(Gingerbread)作業系統,加上Gingerbread在Ubuntu 12.04編譯上有些許地方需要修改,在這裡整理出來順便做個紀錄。



安裝環境:
請參考 "在 Ubuntu 12.04 LTS 安裝 Android SDK&NDK 開發環境"
http://www.cheng-min-i-taiwan.blogspot.tw/2012/05/ubuntu-1204-lts-android-sdk.html

以下是幾項錯誤訊息出現時所需要修改的地方:

....(略)....
frameworks/base/libs/utils/RefBase.cpp: In member function ‘void android::RefBase::weakref_type::trackMe(bool, bool)’:
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
make: *** Waiting for unfinished jobs....
frameworks/base/libs/utils/ResourceTypes.cpp: In member function ‘void android::ResTable::print(bool) const’:
frameworks/base/libs/utils/ResourceTypes.cpp:4369:84: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
frameworks/base/libs/utils/ResourceTypes.cpp:4375:43: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
解決方法是修改
frameworks/base/libs/utils/Android.mk line 60 :
在:
LOCAL_CFLAGS += -DLIBUTILS_NATIVE=1 $(TOOL_CFLAGS)
後面加 -fpermissive :
LOCAL_CFLAGS += -DLIBUTILS_NATIVE=1 $(TOOL_CFLAGS) -fpermissive

===========================================================

host C++: obbtool <= frameworks/base/tools/obbtool/Main.cpp
:0:0: error: "_FORTIFY_SOURCE" redefined [-Werror]

:0: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

解決方法是修改:
build/core/combo/HOST_linux-x86.mk line 61:

把:
HOST_GLOBAL_CFLAGS += -D_FORTIFY_SOURCE=0
改為:
HOST_GLOBAL_CFLAGS += -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0

參考:http://code.google.com/p/android/issues/detail?id=20795

==============================================================

....(略)....
Install: out/host/linux-x86/lib/libneo_util.so
/usr/bin/ld: cannot find -lz
collect2: ld returned 1 exit status
make: *** [out/host/linux-x86/obj/lib/libneo_cgi.so] Error 1
make: *** Waiting for unfinished jobs....
Copying: out/target/common/obj/JAVA_LIBRARIES/core_intermediates/classes-jarjar.jar

安裝libz套件:
$ sudo apt-get install lib32z1-dev

==============================================================
....(略)....
.....bj/STATIC_LIBRARIES/libebl_intermediates/libebl.a
/usr/bin/ld: cannot find -lncurses
collect2: ld returned 1 exit status
make: *** [out/host/linux-x86/obj/EXECUTABLES/adb_intermediates/adb] Error 1
make: *** Waiting for unfinished jobs....
true
解決方法是安裝
$ sudo apt-get install lib32ncurses5-dev

==============================================================
....(略)....
target Java: CtsVerifier (out/target/common/obj/APPS/CtsVerifier_intermediates/classes)
target Static Jar: frameworks-core-util-lib (out/target/common/obj/JAVA_LIBRARIES/frameworks-core-util-lib_intermediates/javalib.jar)
target Java: ExternalSharedPermsBTTestApp (out/target/common/obj/APPS/ExternalSharedPermsBTTestApp_intermediates/classes)
target Java: ExternalSharedPermsDiffKeyTestApp (out/target/common/obj/APPS/ExternalSharedPermsDiffKeyTestApp_intermediates/classes)
cts/apps/CtsVerifier/src/com/android/cts/verifier/PassFailButtons.java:191: onCreateDialog(int,android.os.Bundle) in android.app.Activity cannot implement onCreateDialog(int,android.os.Bundle) in com.android.cts.verifier.PassFailButtons.PassFailActivity; attempting to assign weaker access privileges; was public
    private static
                    ^
1 error
make: *** [out/target/common/obj/APPS/CtsVerifier_intermediates/classes-full-debug.jar] Error 41
make: *** Waiting for unfinished jobs....

解決方法是將OpenJDK改成Oracle (SUN) jdk
$ sudo update-alternatives --config java

==============================================================

1 則留言:

  1. 建議儘量在 UBUNTU 裡使用 Oracle (SUN) JDK。
    之前試過 OpenJDK,只要 Android 的程式碼不包括 cts 的部份,大多數都能編譯成功;但只要包含有 cts 的部份,就編譯失敗了。

    回覆刪除