为bazel,android tensorflow设置targetSdkVersion和compileSdkVersion [英] Setting targetSdkVersion and compileSdkVersion for bazel, android tensorflow

查看:45
本文介绍了为bazel,android tensorflow设置targetSdkVersion和compileSdkVersion的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要帮助来设置目标并分别为bazel编译Sdk版本.

I need help in how to set the target and compile Sdk versions separately for bazel.

我想在教程.按如下所示编辑bazel的WORKSPACE:

I want to run tensorflow on the phone following this tutorial. After editing WORKSPACE for bazel as follows:

android_sdk_repository(
    name = "androidsdk",
    api_level = 24,
    build_tools_version = "24.0.1",
    path = "/home/Android/Sdk",
)

android_ndk_repository(
    name="androidndk",
    path="/home/Android/Sdk/ndk-bundle",
    api_level=21)

安装apk后,手机上出现PARSE ERROR:

I get PARSE ERROR on the phone upon apk installing:

adb install -r bazel-bin/tensorflow/examples/android/tensorflow_demo.apk

我启用了USB调试功能并启用了第三方APK安装.手机使用Android 4.4.4,因此我将WORKSPACE配置更改为与之匹配(SDK管理器已正确安装工具和API),如下所示:

I have usb debugging and 3rd party apk installation enabled. The phone uses Android 4.4.4 so I changed WORKSPACE configuration to match it (tools and API installed by SDK manager properly) as:

android_sdk_repository(
    name = "androidsdk",
    api_level = 19,
    build_tools_version = "19.1.0",
    path = "/home/Android/Sdk",
)

android_ndk_repository(
    name="androidndk",
    path="/home/Android/Sdk/ndk-bundle",
    api_level=21)

建立时为:

bazel build //tensorflow/examples/android:tensorflow_demo

我最终遇到了这种类型的错误:

I end up with few errors of that type:

Error at 5 : /tmp/android_resources_tmp7060220119759636814/merged_resources/values-v21/values.xml:5: error: Error retrieving parent for item: No resource found that matches the given name 'android:Theme.Material.Light'.

以下答案,我应该为编译API版本> 21进行构建,但同时要针对API版本19进行构建.可以很容易地为gradle设置它.但是,我没有找到任何线索来为 bazel .任何建议表示赞赏!

Following this answer, I should build for compile API version > 21 but at the same time target API version 19. It can be easily set for gradle. However I have not found any clue how to do that for bazel. Any suggestions are appreciated!

推荐答案

如果要定位较低的Android API级别,则要编辑的文件实际上是tensorflow/examples/android/AndroidManifest.xml.保持WORKSPACE文件设置为通过sdk安装的最高API级别(可以使用$ ANDROID_HOME/tools/android安装API).

If you want to target a lower Android API level, the file you want to edit is actually tensorflow/examples/android/AndroidManifest.xml. Leave the WORKSPACE file settings at the highest API level you have installed via your sdk (APIs can be installed with $ANDROID_HOME/tools/android).

您可以在AndroidManifest.xml中将最低API级别降低至19,但要注意,除非您替换与camera2 api交互的演示代码(已随API级别添加),否则在运行该演示的电话上会遇到运行时错误.21)与类似的android.hardware.camera代码.

You can lower the min API level to 19 in AndroidManifest.xml, but be aware you will encounter runtime errors on your phone running the demo unless you replace the demo code that interfaces with the camera2 api (which was added with API level 21) with analogous android.hardware.camera code.

这篇关于为bazel,android tensorflow设置targetSdkVersion和compileSdkVersion的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆