编译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

猜你喜欢

转载自blog.csdn.net/yypony/article/details/41693849
14