1. 參考
一篇中文的安裝步驟:http://blog.csdn.net/wei220000/article/details/50985609
原文可參考: https://github.com/tensorflow/tensorflow/tree/master/tensorflow/examples/android
2. 推薦版本組合
bazel 最新版本
SDK build tools 最新版本
NDK: r11c (dl.google.com/android/repository/android-ndk-r11c-linux-x86_64.zip)
3. 注意問題
3.1. bazel版本和ndk版本問題
在2016年11月,bazel的版本升級到了0.4.0,但是依然會出現ndk版本的錯誤:“Could not read RELEASE.TXT in Android NDK”
按照tensorflow的帖子(https://github.com/tensorflow/tensorflow/issues/3175),可以看到解決方法就是限制ndk的版本到r11c以下。
ndk r11c的下載地址:dl.google.com/android/repository/android-ndk-r11c-linux-x86_64.zip
3.2. WORKSPACE文件配置
關於API level 和SDK版本對應的問題,可以從這個網站查找:https://developer.android.com/guide/topics/manifest/uses-sdk-element.html,也可以查看Android Stuido中SDK Manager的列表。
如果API level 和 build tools的版本設置錯誤,常見的錯誤就是出現某個工具找不到,如
“@androidsdk//:zipalign_binary: missing input file '@androidsdk//:build-tools/25.2.3/zipalign”
另外,api_level必須設置為比23大的數,否則可能出現以下一類的錯誤(https://github.com/tensorflow/tensorflow/issues/3847)
error: cannot find symbol
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
^
symbol: variable M
location: class VERSION_CODES
3.3.一些依賴包
如果直接用git clone指令下載tensorflow,就可能漏下一些依賴包,這樣在bazel編譯的過程中就需要聯網下載依賴包。可以在git clone的時候加入“--recurse_submodules”選項即可。
4. 運行結果
運行的而結果是視頻圖像以及預測的結果和概率。