1.編譯環境搭建
- ubuntu14.04
- jdk1.8.0(JDK)
- android-ndk-r18b(NDK)
- android-sdk-linux(SDK)
1.1 設置環境變量
vim ~/.bashrc
1.2 在打開的.bashrc文件最後添加如下代碼
#set jdk
export JAVA_HOME=/usr/lib/jvm/jdk1.8.0_201(你自己的jdk路徑)
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
#set ndk
export ANDROID_NDK=/home/adolph/tools/android-ndk-r18b(你自己的ndk路徑)
export PATH=${PATH}:$ANDROID_NDK
#set android-sdk
export ANDROID_SDK=/home/adolph/tools/android-sdk-linux(你自己的sdk路徑)
export PATH=$PATH:${ANDROID_SDK}/tools
export PATH=$PATH:${ANDROID_SDK}/platform-tools
1.3 在終端中輸入如下命令使環境變量生效
source ~/.bashrc
2.安裝編譯VLC所需的工具包
以下是官方文檔提供的安裝命令,實際操作中建議一個一個安裝
sudo apt-get install automake ant autopoint cmake build-essential libtool-bin \ patch pkg-config protobuf-compiler ragel subversion unzip git \ openjdk-8-jre openjdk-8-jdk flex python wget
因爲我們已經安裝了jdk,所以openjdk-8-jre openjdk-8-jdk可以不用安裝。
如果是64位ubuntu,爲了防止後面少走彎路,需要安裝32位的庫。
sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install zlib1g:i386 libstdc++6:i386 libc6:i386
3.開始編譯VLC
3.1 下載VLC編譯代碼
git clone https://code.videolan.org/videolan/vlc-android.git
3.2 進入到vlc-android目錄,執行編譯指令開始編譯
cd vlc-android
sh compile.sh -a armeabi-v7a
4.編譯中可能出現的問題
4.1 “Unrecognized syntax identifier “proto3””
解決辦法:
新版VLC要求使用protobuf3,而ubuntu14.04的版本爲2.x,所以我們需要安裝新的版本。
1、查看protobuf版本
protoc --version
2、下載:https://github.com/google/protobuf/releases/download/v3.1.0/protobuf-cpp-3.1.0.tar.gz
3.安裝
sudo tar zxvf ./protobuf-cpp-3.1.0.tar.gz #解壓
cd ./protobuf-3.1.0/ #解壓出的文件夾
./configure #運行configure
make
make check
sudo make install
make clean
sudo ldconfig #更新shared library cache
4.2 git下載慢的問題
解決辦法:
https://blog.csdn.net/weixin_37910453/article/details/86655613
4.3 python版本低
File "/home/adolph/tools/vlc-android/vlc/extras/tools/meson/mesonbuild/interpreterbase.py", line 577
return {**l, **r}
^
SyntaxError: invalid syntax
解決辦法:
安裝python3.5以上版本
https://blog.csdn.net/qq_39734379/article/details/84580645
4.4 gettext的版本號不對
androideabi/share/aclocal
autoreconf: Entering directory `.’
autoreconf: running: autopoint --force
autopoint: *** The AM_GNU_GETTEXT_VERSION declaration in your configure.ac
file requires the infrastructure from gettext-0.19.3 but this version
is older. Please upgrade to gettext-0.19.3 or newer.
autopoint: *** Stop.
autoreconf: autopoint failed with exit status: 1
make: *** [.gpg-error] Error 1
contribs: make failed
解決辦法:
1 通過gettext --version命令查看當前機器gettext的版本號,顯示如下:
gettext (GNU gettext-runtime) 0.18.3
Copyright (C) 1995-1997, 2000-2007 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by Ulrich Drepper.
2 通過grep --include=configure.ac -rn AM_GNU_GETTEXT_VERSION .命令查看哪些文件涉及版本號,顯示如下:
./vlc/configure.ac:493:AM_GNU_GETTEXT_VERSION([0.19.8])
./vlc/contrib/contrib-android-arm-linux-androideabi/gnutls/configure.ac:256:AM_GNU_GETTEXT_VERSION([0.19])
./vlc/contrib/contrib-android-arm-linux-androideabi/libgpg-error/configure.ac:154:AM_GNU_GETTEXT_VERSION([0.18.3])
3修改以上文件中AM_GNU_GETTEXT_VERSION爲自己的版本號0.18.3
4.5 安裝的libtool存在問題
.../configure:line 9171:syntax error near unexpected token 'dlopen'
../configure line 9171:'LT_INIT(dlopen win32-dll shared disable-static)'
解決辦法:進入vlc-android/vlc目錄下執行autoreconf命令
在運行的過程中可能會出現以下錯誤:
Makefile.am:10: error: Libtool library used but 'LIBTOOL' is undefined
Makefile.am:10: The usual way to define 'LIBTOOL' is to add 'LT_INIT'
Makefile.am:10: to 'configure.ac' and run 'aclocal' and 'autoconf' again.
Makefile.am:10: If 'LT_INIT' is in 'configure.ac', make sure
Makefile.am:10: its definition is in aclocal's search path.
解決辦法:
需要在目錄中運行libtoolize,然後重新運行:
> aclocal
> autoheader
> autoreconf
編譯完成後在vlc-android/vlc-android/build/outputs/apk/dev目錄中會生成APK文件
5.編譯aar文件
第四步執行成功後,可以執行下面這個命令來生成aar文件
sh compile.sh -l -a armeabi-v7a -r
編譯成功後會在vlc-android/libvlc/build/outputs/aar中生成aar文件
最後提供JDK,NDK,SDK包和我已經編譯好的APK文件和AAR文件
鏈接: https://pan.baidu.com/s/1nbdKXMHnOl743E6FbdVLQw 提取碼: fs3c
參考:
https://blog.csdn.net/wkw1125/article/details/56845405
https://blog.csdn.net/zhuyunier/article/details/82843958
https://wiki.videolan.org/AndroidCompile/