編輯:關於Android編程
在Ubuntu 14.04 32bit麒麟版上編譯Android2.3.4源碼全過程
真正地體會到:編譯真是個苦力活,耗費一天的時間,終於將android2.3.4源碼編譯成功!為此將此過程中遇到的問題詳細記錄如下,特供大家參考!
環境:Android2.3.4源碼+Ubuntu14.04 32 位+jdk1.6(現在官網上要注冊才能下載,為此將jdk安裝包貢獻給大家)
源碼和jdk請見附件,有需要的可以自行下載!
本人以root權限登錄的,所以涉及到權限的問題,命令前面無須添加sudo。
問題列表:
PS:android源碼編譯需要Ubuntu 64bit環境,因此需要修改,方法很簡單,在此不啰嗦了,請google即可。
[1] 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]
ssize_t i = indexOfKey(key);
cc1plus: warning: unrecognized command line option -Wno-format-y2k-fpermissive [enabled by default]
make: *** [out/host/linux-x86/obj/EXECUTABLES/aapt_intermediates/AaptAssets.o] 錯誤 1
Fix:
frameworks/base/tools/aapt/Android.mk
在第31行後面增加一行:
LOCAL_CFLAGS += -fpermissive
[2] /bin/bash: flex: 未找到命令
缺什麼命令,就添加什麼命令!
Fix :apt-get install flex
[3] build/tools/merge-event-log-tags.py 權限不夠
chmod 777 build/tools/merge-event-log-tags.py
[4] 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 https://github.com/CyanogenMod/android_external_srec/commit/4d7ae7b79eda47e489669fbbe1f91ec501d42fb2.diff
patch -p1 < 4d7ae7b79eda47e489669fbbe1f91ec501d42fb2.diff
rm -f 4d7ae7b79eda47e489669fbbe1f91ec501d42fb2.diff
cd ../..
[5] /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
[6] 錯誤1:out/host/linux-x86/obj/SHARED_LIBRARIES/libdvm_intermediates/native/dalvik_system_Zygote.o
解決方法:
vm/native/dalvik_system_Zygote.c
#include Dalvik.h
#include native/InternalNativePriv.h
下面加上一行:
#include
[7] arm-eabi-gcc: error trying to exec 'cc1': execvp: No such file or directorymake: *** [out/target/product/generic/obj/lib/crtbegin_dynamic.o] 錯誤 1
Fix:gcc g++版本過高,應該都降級為4.4才行
$sudo apt-get install g++-4.4
$sudo apt-get install g++-4.4-multilib
$sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.4 40
$sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.6 60
$sudo update-alternatives --config g++
Selection Path Priority Status
------------------------------------------------------------
* 0 /usr/bin/g++-4.6 60 auto mode
1 /usr/bin/g++-4.4 40 manual mode
2 /usr/bin/g++-4.6 60 manual mode
選擇1.
如果想改為高版本的隨時用update-alternatives --config 命令切換!
修改後第一次編譯仍然存在錯誤,第二次編譯就沒有錯誤了,具體原因我也不清楚。
[8] 沒有規則可以創建“out/target/product/generic/obj/SHARED_LIBRARIES/libcameraservice_intermediates/LINKED/libcameraservice.so”需要的目標“out/target/product/generic/obj/lib/libcamera.so”。 停止
修改/home/Android-2.3.4/frameworks/base/services/camera/Android.mk
LOCAL_PATH:= $(call my-dir)
# Set USE_CAMERA_STUB if you don't want to use the hardware camera.
# force these builds to use camera stub only
ifneq ($(filter sooner generic sim,$(TARGET_DEVICE)),)
USE_CAMERA_STUB:=true
endif
USE_CAMERA_STUB:=true
ifeq ($(USE_CAMERA_STUB),)
USE_CAMERA_STUB:=true
endif
[9] sh: 1: gperf: not foundcalling gperf failed: 32512 at ./makeprop.pl line 96.
Fix:apt-get install gperf
[10] out/target/product/generic/obj/STATIC_LIBRARIES/libwebcore_intermediates/WebCore/HTMLNames.h
Fix:sudo apt-get install libswitch-perl
[11] out/target/product/generic/obj/EXECUTABLES/BufferQueue_test_intermediates/BufferQueue_test.o
Fix:
其實是讀取錯文件了,你把正確文件拷貝過去就ok了
# cp system/media/opensles/libopensles/OpenSLESUT.h system/media/opensles/include/SLES/OpenSLESUT.h
[12] target Executable: BufferQueue_test (out/target/product/generic/obj/EXECUTABLES/BufferQueue_test_intermediates/LINKED/BufferQueue_test)
out/target/product/generic/obj/lib/libOpenSLES.so: undefined reference to `typeinfo for android::SortedVectorImpl'
out/target/product/generic/obj/lib/libOpenSLES.so: undefined reference to `vtable for __cxxabiv1::__vmi_class_type_info'
collect2: ld returned 1 exit status
make: *** [out/target/product/generic/obj/EXECUTABLES/BufferQueue_test_intermediates/LINKED/BufferQueue_test] 錯誤
Fix:change system/media/opensles/libopensles/IAndroidEffect.c to IAndroidEffect.cpp
$mv IAndroidEffect.c IAndroidEffect.cpp
Android.mk change IandroidEffect.c to IAndroidEffect.cpp
Generated: (out/target/product/generic/android-info.txt)
Target system fs image: out/target/product/generic/obj/PACKAGING/systemimage_intermediates/system.img
Install system fs image: out/target/product/generic/system.img
Target ram disk: out/target/product/generic/ramdisk.img
Target userdata fs image: out/target/product/generic/userdata.img
Installed file list: out/target/product/generic/installed-files.txt
執行make sdk 將編譯後的代碼打包成sdk
Package SDK: out/host/linux-x86/sdk/android-sdk_eng.root_linux-x86.zip
運行android模擬器
過程雖然簡單,但是遇到各種問題,也花了將近2個小時,不過最後還是成功了!
我執行了如下的代碼
首先配置環境變量:
gedit /etc/profile
export ANDROID_BUILD_TOP=/home/Android-2.3.4/
export ANDROID_PRODUCT_OUT=/home/Android-2.3.4/out/target/product/generic
export ANDROID_PRODUCT_OUT_BIN=/home/Android-2.3.4/out/host/linux-x86/bin
export PATH=$PATH:/home/Android-2.3.4/out/host/linux-x86/
source /etc/profile
啟動模擬器:
由於模擬器的默認kernel路徑有問題,所以需要加上正確的kernel路徑才能成功啟動。
root@user:/home/Android-2.3.4# emulator
emulator: ERROR: bad workspace: cannot find prebuilt kernel in: /home/Android-2.3.4//prebuilts/qemu-kernel/arm/kernel-qemu
root@user:/home/Android-2.3.4# emulator -kernel ./prebuilt/android-arm/kernel/kernel-qemu
1.知識點 在了解Scorller類之前應先知道View的ScrollTo(int x, int y)/ScrollBy(int x, int y)之間的區別,了解什
前幾天完成了一個客戶端小功能,使用html頁面登錄, 拿到cookie之後,傳遞給httpclient完成業務邏輯的訪問,現在把基本的流程整理記錄一下。 首先來一張a
功能描述菜單分左右兩側,整體可以滑動,效果如下功能分析widthMeasureSpec:期望值組成: 32位的010101010101011010101組成 頭2位:代表
一、環境配置1、在Android Studio中,在.src/main目錄下新建一個java-gen文件夾,和java文件夾同級。用於存放greenDAO生成的DaoMa