編譯Kodi(XBMC 14) 和XBMC-13.2-Gotham版本的記錄

編譯Kodi(XBMC 14) 和XBMC-13.2-Gotham版本的記錄

一、環境搭建
android sdk升級更新時,解決google連不上的問題參考:
更新ADT時無法解析https://dl-ssl.google.com/android/eclipse

解決辦法
1). 使用http協議而不是https協議,因爲https協議進行了加密處理,大陸因爲無法審查,>直接封死,而http協議則進行過濾處理,如果不訪問亂七八糟的東西,更新個SDK還是沒問>題的。
在SDK Manager下Tools->Options打開了SDK Manager的Settings,選中“Force https://… sources to be fetched using http://…”,強制使用http協議。
2). 修改hosts文件
Windows在C:\WINDOWS\system32\drivers\etc目錄下,
Linux用戶打開/etc/hosts文件。打開文件後添加以下內容。

#Google主頁
203.208.46.146 www.google.com
#這行是爲了方便打開Android開發官網 現在好像不翻牆也可以打開
74.125.113.121 developer.android.com
#更新的內容從以下地址下載
203.208.46.146 dl.google.com
203.208.46.146 dl-ssl.google.com



二、按照官方文檔編譯docs/README.android
1.搭建編譯環境:
r9版本的ndk源碼下載地址參見:
http://blog.csdn.net/ultrapro/article/details/12071279
r14版本的sdk下載地址:http://dl.google.com/android/android-sdk_r14-linux.tgz
13.2版本的 XBMC 源碼必須使用 android-ndk-r9 版本的 NDK,r9b 不行,後面會報錯。參考:http://forum.xbmc.org/showthread.php?tid=177292
下載android-ndk-r9,地址:http://dl.google.com/android/ndk/android-ndk-r9-linux-x86_64.tar.bz2
建立android的工具鏈
解壓ndk到自定義的安裝目錄:
#cd $HOME/bin
#tar -xjf $HOME/download/android-ndk-r9-linux-x86_64.tar.bz2
編譯自己的toolchain:
#cd android-ndk-r9
#ls platforms
#cd build/tools
#./make-standalone-toolchain.sh --ndk-dir=../../ --install-dir=../../toolchains/arm-linux-androideabi-4.8/android-14 --platform=android-14 --toolchain=arm-linux-androideabi-4.8 --system=linux-x86_64
注:--install-dir爲編譯生成的toolchain存放目錄,此處我們將存放目錄放在ndk自帶的工具鏈目錄下,--ndk-dir爲ndk路徑
創建一個debug key 來簽名debug apk
keytool -genkey -keystore ~/.android/debug.keystore -v -alias androiddebugkey -dname "CN=Android Debug,O=Android,C=US" -keypass android -storepass android -keyalg RSA -keysize 2048 -validity 10000

2.開始編譯依賴庫
下載代碼:
xbmc所有版本(非git方式)的源代碼鏈接:
https://github.com/xbmc/xbmc/releases

  # cd $HOME
   # git clone git://github.com/xbmc/xbmc.git xbmc-android
   # cd xbmc-android
   # git submodule update --init addons/skin.touched
(14的kodi版本改成: git submodule update --init addons/skin.re-touched)
編譯依賴庫:
  # cd $HOME/xbmc-android/tools/depends
   # ./bootstrap
   # ./configure --help
根據自己的環境,參考 tools/depends/README設置自己的configure參數
#./configure --with-tarballs=/home/yaoyang/projects/xbmc-13.2-tarballs --host=arm-linux-androideabi --with-sdk-path=/home/yaoyang/bin/adt-bundle-linux-x86_64-20130729/sdk/ --with-ndk=/home/yaoyang/bin/android-ndk-r9 --with-toolchain=/home/yaoyang/bin/android-ndk-r9/toolchains/arm-linux-androideabi-4.8/android-14/ --prefix=/home/yaoyang/projects/xbmc-13.2-depends
(編譯14的kodi版本時android-ndk-r9d時的路徑:
#./configure --with-tarballs=/home/yaoyang/projects/xbmc-android-tarballs --host=arm-linux-androideabi --with-sdk-path=/home/yaoyang/bin/adt-bundle-linux-x86_64-20130729/sdk/ --with-ndk=/home/yaoyang/bin/android-ndk-r9d --with-toolchain=/home/yaoyang/bin/android-ndk-r9d/toolchains/arm-linux-androideabi-4.8/android-14/ --prefix=/home/yaoyang/projects/xbmc-android-depends)
此處注意 --with-toolchain 必須與前面搭建編譯環境中下載並安裝ndk後,編譯自己的toolchain時的安裝路徑 --install-dir 一致,否則會報 pcre-8.33 編譯錯誤
--with-tarballs和--prefix爲編譯後依賴庫的安裝路徑 --with-sdk-path爲sdk的安裝路徑,--with-ndk爲ndk的安裝路徑
#make -j20

編譯xbmc庫
#make -C tools/depends/target/xbmc
#make
在13.2-Gtham版本時,會遇到下面的錯誤:

CPP     xbmc/android/activity/AndroidJoyStick.o
In file included from AndroidJoyStick.cpp:22:0:
AndroidExtra.h:35:25: error: expected identifier before numeric constant
 #define AKEYCODE_ESCAPE 111
                         ^
AndroidExtra.h:35:25: error: expected '}' before numeric constant
AndroidExtra.h:35:25: error: expected unqualified-id before numeric constant
In file included from /home/yaoyang/bin/android-ndk-r9d/toolchains/arm-linux-androideabi-4.8/android-14/sysroot/usr/include/android/input.h:45:0,
                 from /home/yaoyang/bin/android-ndk-r9d/toolchains/arm-linux-androideabi-4.8/android-14/sysroot/usr/include/android/native_activity.h:27,
                 from XBMCApp.h:27,
                 from AndroidJoyStick.cpp:23:
/home/yaoyang/bin/android-ndk-r9d/toolchains/arm-linux-androideabi-4.8/android-14/sysroot/usr/include/android/keycodes.h:259:1: error: expected declaration before '}' token
 }
 ^
make[1]: *** [AndroidJoyStick.o] Error 1
make: *** [xbmc/android/activity/activity.a] Error 2

解決方案:使用android-ndk-r9,而不是android-ndk-r9d。
參見鏈接:http://forum.xbmc.org/showthread.php?tid=180128

#make apk
在13.2-Gotham版本時,會出現以下錯誤:

mkdir -p tmp/res; /home/yaoyang/bin/adt-bundle-linux-x86_64-20130729/sdk//platform-tools/aapt c -S xbmc/res -C tmp/res; cp -r -n xbmc/res tmp/ || true
/bin/sh: 1: /home/yaoyang/bin/adt-bundle-linux-x86_64-20130729/sdk//platform-tools/aapt: not found
/home/yaoyang/bin/adt-bundle-linux-x86_64-20130729/sdk//platform-tools/aapt p -f -I /home/yaoyang/bin/adt-bundle-linux-x86_64-20130729/sdk//platforms/android-14/android.jar -S tmp/res/ -M xbmc/AndroidManifest.xml -F images/xbmcapp-debug-skeleton.apk -J xbmc/src
make[1]: /home/yaoyang/bin/adt-bundle-linux-x86_64-20130729/sdk//platform-tools/aapt: Command not found
make[1]: *** [extras] Error 127
make[1]: Leaving directory `/home/yaoyang/projects/xbmc-13.2-Gotham/tools/android/packaging'
make: *** [apk] Error 2

原因:
sdk的版本中沒有aapt命令,給補上

三、編譯文件(Makefile):
1.apk的編譯Makefile:
tools/android/packaging/Makefile
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章