TensorFlow on Android Demo (1)

Source: Internet
Author: User

When reproduced, please specify the source: Xiu Yu Xuan Chen

System Environment Description:

------------------------------------

Operating system: Ubunt 14.03 _ x86_64 operating system

Memory: 8GB

HDD 500G

------------------------------------

First, compile the TensorFlow on Android Demo 1.1 build environment

L Download TensorFlow

First, select a directory to download the source code for TensorFlow on GitHub with the Git command as follows:

TensorFlow after the download is complete, the tensorflow/tensorflow/examples/android/directory Below is an example of Android.

L Build Android Environment

1. Build the Java Environment

Ubunt 64 Under the Java environment no longer repeat, give the operation instructions:

Http://jingyan.baidu.com/article/5d368d1e12a1af3f60c0570a.html

PS need to explain is the best jre_home also set out.

2. Build the SDK Environment

Download and Unzip SDK Tools:

The SDK is given here:

http://www.androiddevtools.cn/

If you feel the Android SDK version is not high enough, you can download it by downloading Android Studio 2.1 and then using the Download tool in Android Srtudio. Given Android Studio: (no need to set proxy or mirror address)

Https://developer.android.com/studio/index.html

After the SDK download, use the unzip command to unzip the directory as follows:

After downloading Sdktools, you will get a directory like this

To view the Android-sdk-linux directory:

There are files in its directory:

Android-sdk-linux

|----Add-ons:google API

|----platforms: for storing Android level API.

|----Platform-tools: versions of the SDK. SDK versions by API level

|----Tools: Common tools for each version of the SDK. such as ADB, and AAPT, Aidl, DX and other documents

|----Temp: Temporary clip, typically used during SDK update installation.

(PS Chart Red directory is built Android complete environment and then manually added, these directories and files will be used later)

The next step is to install Build_tools, which is the build_tools required for Android development, to download and extract the entire folder assignment, or to move to the directory >/build-tools folder < your SDK.

If you feel the hassle, you can install the Android Studio IDE and take advantage of the IDE's own Android Pakage Manager

Help download.

3. Build the NDK Environment

NDK, I found it in a Chinese address, download Android-ndk-r11b-linux-x86_64.zip in Ubuntu.

http://www.androiddevtools.cn/

The NDK directory is full, self-extracting, no need to add any files.

L Mounting Bazel

Bazel is a build tool, a tool that can run compilation and test to assemble software, just like make, Ant, Gradle, Buck, Pants, and maven. This tool will be used in the future when compiling.

According to the Reading Readme:

Https://github.com/tensorflow/tensorflow/tree/master/tensorflow/examples/android

How to Bazel in the.

1.2 Compiling Demo

First modify the workspace in the root directory of the TensorFlow

After the modification, you can build the directory with Bazel first

1.3 Run

After the compilation is successful, the default will be under the Tensorflow/bazel-bin/tensorflow/examples/android directory

Generate the TensorFlow Demo we want

Ii. Errors and Workarounds

Bazel-out/host/bin/external/androidsdk/aapt_binary.runfiles/androidsdk/build-tools/23.0.1/aapt:erro

ERROR:/home/master/programes/android/tensorflow/tensorflow/examples/android/build:47:1: Processing Android Resources for//tensorflow/examples/android:tensorflow_demo failed:namespace-sandbox failed:error executing command/ home/master/.cache/bazel/_bazel_master/65c2377a99cb38c469b4db23ae21783d/execroot/tensorflow/_bin/ Namespace-sandbox ... (remaining argument (s) skipped).

Solution:

Check log to know:

Error while loading shared Libraries:libz.so.1:cannot open Shared object file:no such file or dir

So guess: The reason for the error is:

1 There is a problem when configuring in workspace.

2 Ubuntu's own problems

So I know: is the ubuntu64 bit missing 32 bits of the partial class library, then execute the command to install:

Final compile succeeded::

Reference documents:

Http://www.cnblogs.com/tao560532/p/4249084.html

Http://stackoverflow.com/questions/16588969/android-hello-world-compile-error-intellij-cannot-find-aapt

Https://developer.android.com/studio/releases/build-tools.html

Http://stackoverflow.com/questions/17020298/android-sdks-build-tools-17-0-0-aapt-error-while-loading-shared-libraries-libz

http://blog.csdn.net/g457499940/article/details/38718549

http://forums.xamarin.com/discussion/20505/ Error-xa5205-cannot-find-aapt-exe-please-install-the-android-sdk-build-tools-package

http://blog.csdn.net/wei220000/article/details/50985609

TensorFlow on Android Demo (1)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.