可以参考官网:https://github.com/tensorflow/tensorflow/tree/master/tensorflow/examples/android#android-studio

官网讲的很简单:

Android Studio may be used to build the demo in conjunction with Bazel. First, make sure that you can build with Bazel following the above directions. Then, look at build.gradle and make sure that the path to Bazel matches that of your system.

At this point you can add the tensorflow/examples/android directory as a new Android Studio project. Click through installing all the Gradle extensions it requests, and you should be able to have Android Studio build the demo like any other application (it will call out to Bazel to build the native code with the NDK).

简单地讲:就是

1、安装bazel

2、下载tensorflow官网代码,在tensorflow/examples/android下的build.gradle中修改bazel的路径

3、用android studio 打开tensorflow/examples/android

4、gradle会根据配置说缺少什么什么版本的api,就直接anzhuang(安装)

5、run

然后报错:

* What went wrong:
Execution failed for task ':buildNativeBazel'.
> Process 'command '/usr/bin/bazel'' finished with non-zero exit value 1

其实,这就是buildNativeBazel,用ctrl+shift+f,输入buildNativeBazel,有兩個結果:

def nativeBuildRule = 'buildNativeBazel'
task buildNativeBazel(type: Exec) {
workingDir '../../..'
commandLine bazelLocation, 'build', '-c', 'opt', \
'tensorflow/examples/android:tensorflow_native_libs', \
'--crosstool_top=//external:android/crosstool', \
'--cpu=' + cpuType, \
'--host_crosstool_top=@bazel_tools//tools/cpp:toolchain'
}

第一条结果就是一个定义,没什么用。主要是第二条,发现执行这个命令,bazel build ....执行的目录是在tensorflow下,所以想到

官网上的Building the Demo with TensorFlow from Source

需要配置

Edit WORKSPACE

NOTE: As long as you have the SDK and NDK installed, the ./configure script will create these rules for you. Answer "Yes" when the script asks to automatically configure the ./WORKSPACE.

The Android entries in <workspace_root>/WORKSPACE must be uncommented with the paths filled in appropriately depending on where you installed the NDK and SDK. Otherwise an error such as: "The external label '//external:android/sdk' is not bound to anything" will be reported.

Also edit the API levels for the SDK in WORKSPACE to the highest level you have installed in your SDK. This must be >= 23 (this is completely independent of the API level of the demo, which is defined in AndroidManifest.xml). The NDK API level may remain at 14.

也就是直接打开WORKSPACE文件,将下面的填上就好了,注意andriod studio 最新的是安装ndk16,现在bazel还不支持,所以自己下载r14b,解压,然后路径填写自己解压的就可以,而sdk version 也就是api level,填写和在tensorflow/examples/android下的build.gradle中使用的版本一致就可以,因为android studio 的gradle会自动下载相应的版本,就是“4、gradle会根据配置说缺少什么什么版本的api,就直接anzhuang(安装)”

#android_sdk_repository(
#    name = "androidsdk",
#    api_level = 23,
#    # Ensure that you have the build_tools_version below installed in the
#    # SDK manager as it updates periodically.
#    build_tools_version = "25.0.2",
#    # Replace with path to Android SDK on your system
#    path = "<PATH_TO_SDK>",
#)
#
# Android NDK r12b is recommended (higher may cause issues with Bazel)
#android_ndk_repository(
#    name="androidndk",
#    path="<PATH_TO_NDK>",
#    # This needs to be 14 or higher to compile TensorFlow.
#    # Note that the NDK version is not the API level.
#    api_level=14)

取消#注释,然后填入,再run就ok啦。

参考:

http://blog.csdn.net/masa_fish/article/details/54585537

http://blog.csdn.net/masa_fish

TensorFlow Android Camera Demo 使用android studio编译安装和解决Execution failed for task ':buildNativeBazel'报错的更多相关文章

  1. 【Android Studio使用教程6】Execution failed for task ':×××:compileReleaseAidl'

    使用Android Studio运行项目时候,经常会报一些错,比如 Execution failed for task ':×××:processReleaseResources' Execution ...

  2. 【Android】AndroidStudio打包apk出现的一些问题 `Error:Execution failed for task ':app:lintVitalRelease'.

    作者:程序员小冰,CSDN博客:http://blog.csdn.net/qq_21376985, QQ986945193 公众号:程序员小冰 1,错误代码: `Error:Execution fai ...

  3. Android 解决Execution failed for task ':app:clean.'报错

    说实话,我还真是没见过比Execution failed for task ':app:clean.'更为恶心,更为不要脸的bug啦,代码没啥问题,一下子行让你爽爽,一下子又不鸟你啦,研究了下,终于找 ...

  4. 解决添加codova plugin 编译出现问题:Execution failed for task ':processDebugManifest'.

    问题背景: ionic3项目上,添加cordova-plugin-cszbar,编译运行在android平台上 ,结果编译不成功.出现以下问题. Element uses-feature#androi ...

  5. Android Studio2.1 Run APP:Error: Execution failed for task

    Android Studio2.1 Run APP时,遇到错误 Error: Execution failed for task ':app:clean'. Unable to delete file ...

  6. Android Studio 编译错误 Error:Execution failed for task ':app:buildInfoDebugLoader'.

    今天来到打开昨天的项目运行正常,然后改动了一点代码编译报错: Error:Execution failed for task ':app:buildInfoDebugLoader'. > Exc ...

  7. Android Studio编译开源项目(含NDK开发)常见报错

    1.未设置NDK的路径 Error:Execution failed for task ':library:ndkBuild'. > A problem occurred starting pr ...

  8. Android Studio 中 FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':compileDebugAidl'.的问题解答

    Android Studio 中 FAILURE: Build failed with an exception. * What went wrong: Execution failed for ta ...

  9. android排除报很多错方法 Execution failed for task ':app:compileDebugJavaWithJavac' in Android Studio

    android排除报很多错方法1.回撤对应layout的xml改动2.回撤对应java的改动3.重命名文件后导致的资源不对应 Execution failed for task ':app:compi ...

随机推荐

  1. 我的第一个爬虫程序:利用Python抓取网页上的信息

    题外话 我第一次听说Python是在大二的时候,那个时候C语言都没有学好,于是就没有心思学其他的编程语言.现在,我的毕业设计要用到爬虫技术,在网上搜索了一下,Python语言在爬虫技术这方面获得一致好 ...

  2. spring boot 项目无法访问静态页面

  3. Centos6.5搭建Elasticsearch

    ElasticSearch是基于Lucene的搜索服务.支持分布式多用户能力的全文搜索引擎,提供RESTful web接口.Elasticsearch是用Java开发的,Apache旗下开源项目,支持 ...

  4. redis 远程连接出错的解决办法

    1. 配置防火墙端口 redis系统的默认端口是6379端口. # 打开端口 $ firewall-cmd --zone=public --add-port=6379/tcp --permanent ...

  5. spring--多人开发,模块化配置

    需要在配置文件中配置: <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="h ...

  6. Python3 Flask+nginx+Gunicorn部署(上)

    前言:一般在本地运行flask项目通常是直接python3 文件名.py,然后打开:http://127.0.0.1:5000 查看代码结果 这次主要是记录flask在python3 环境结合ngin ...

  7. zabbix 与 nginx (五)

    zabbix监控nginx的大概流程为:   1:被监控端的nginx开启stub_status模块 2:通过脚本的方式获取nginx的状态值 3:修改被监控端的配置文件,Userparameter= ...

  8. ubuntu18关闭系统自动更新

    ubuntu18.04关闭系统自动更新有两个方法:1.修改配置文件 修改配置文件/etc/apt/apt.conf.d/10periodic#0是关闭,1是开启,将所有值改为0vi etc/apt/a ...

  9. 由override 和 overload 引发的学习感悟

    工作已三年的我,竟然面试的时候去裸考了.想当然的认为有很多东西会在工作中不知不觉积累下来,现在想想,真是扯淡... 我的三年的工作经验是开发测试的工作,主要负责测试用例的自动化实现,稍深一些的是自动化 ...

  10. PAT 乙级1093 字符串A+B (20 分)

    1093 字符串A+B (20 分) 给定两个字符串 A 和 B,本题要求你输出 A+B,即两个字符串的并集.要求先输出 A,再输出 B,但重复的字符必须被剔除. 输入格式: 输入在两行中分别给出 A ...