Tensorflow android example won't build - android

I'm trying to build the android example from tensorflow but keep running into an annoying build error. My steps so far:
installed android studio for the SDK. (v24)
downloaded android NDK 10e (other versions don't seem to work)
aditionally installed SDK build tools 23.0.1 (v24 doesn't seem to work)
added an assets folder to the android example with the inception model
edited the WORKSPACE file to point to the NDK/SDK locations.
I tried several versions of TF, but I keep getting the error. Any ideas?
The error:
C++ compilation of rule '#protobuf//:protobuf' failed: namespace-sandbox failed: error executing command /home/sander/.cache/bazel/_bazel_sander/577a8dcd97360f56540bc1f3f08ac240/tf-cat-face/_bin/namespace-sandbox ... (remaining 51 argument(s) skipped).
src/main/tools/namespace-sandbox.c:697: execvp(argv[0], argv): No such file or directory
Target //tensorflow/examples/android:tensorflow_demo failed to build
Use --verbose_failures to see the command lines of failed build steps.

Bazel creates a sandbox for each compilation step, so your build doesn't include anything unintentional. However, last time I checked, TF can't use the sandbox because its build isn't completely hermetic. The errors you're getting are sandboxing errors (it can't find something that's supposed to be in the sandbox) so you can turn the sandbox off with --genrule_strategy=standalone and --spawn_strategy=standalone flags, e.g.,
bazel build --genrule_strategy=standalone --spawn_strategy=standalone //path/to/your:target

If you're looking for a quick way to build the TensorFlow Android demo app, check out this tutorial I wrote.
The articles explain more, but I created this Docker image which contains all the dependencies you need so that you can just pull the Docker image and build the Android demo app.
The one gotcha I found was that I needed to pass the --local_resources option to ensure that builds succeed inside Docker (otherwise they run out of memory, even on my 3.1 GHz, 16GB RAM Macbook Pro):
bazel build -c opt --local_resources 4096,4.0,1.0 -j 1 //tensorflow/examples/android:tensorflow_demo

Related

Qt for android: project error cannot run target compiler

I compile for the first time "toutchinteraction.pro" from Qt for android examples.
I installed sdk manager from android studio, all my android setup are well configured except for openssls which is optional (I didn't install it).
When I open the example project from Qt creator, I have the following error: Project ERROR: Cannot run target compiler 'C:\Program Files (x86)\Android\android-sdk\ndk\21.3.6528147/toolchains/llvm/prebuilt/windows-x86_64/bin/clang++
Do you think that the white space inside the path makes this issue?
I can confirm you that it is the whitespace, I had the same issue, tried everything, and in the end installing the SDK and NDK in a path without whitespace solved the problem

how can I compile android project to apk

at the first experience with android, I don't install android studio!
Just cloned a project and search according to see gradlew.bat file. but when I run it:
PS D:\projects\android> .\gradlew.bat assembleDebug g
FAILURE: Build failed with an exception.
* Where:
Settings file 'D:\projects\android\settings.gradle'
* What went wrong:
Could not compile settings file 'D:\projects\android\settings.gradle'.
> startup failed:
General error during semantic analysis: Unsupported class file major version 61
java.lang.IllegalArgumentException: Unsupported class file major version 61
at groovyjarjarasm.asm.ClassReader.<init>(ClassReader.java:196)
at groovyjarjarasm.asm.ClassReader.<init>(ClassReader.java:177)
at groovyjarjarasm.asm.ClassReader.<init>(ClassReader.java:163)
at groovyjarjarasm.asm.ClassReader.<init>(ClassReader.java:284)
at org.codehaus.groovy.ast.decompiled.AsmDecompiler.parseClass(AsmDecompiler.java:81)
...
my settings.gradle:
include ':vlc-android-sdk-3.0.0'
include ':app'
rootProject.name = "DSM"
is SDK needed? what's emulator has used in this link: https://developer.android.com/studio/build/building-cmdline
how can I build apk finally?
Yes, you need the Android SDK to build, run and debug apps! if you don't want to install Android Studio, you can download the basic Android command-line tools from this link: https://developer.android.com/studio#downloads. You can use the included SDK manager to download other SDK packages.
The above-mentioned error is also thrown when an incorrect JDK version is installed in your system. [Also] make sure you also set up environment variables like ANDROID_HOME, JAVA_HOME, and platform-tools with their respective locations on your pc. most of this setup is taken care of by default on installing Android Studio!
I never use this method to compile my android project into an .apk
I use an alternative method which I find easier than compiling .apk in the android project.
What I do is -
Build the Android Project by clicking on the build icon.
After the build is successful, Open File Explorer of on your PC.
Then going to the file location - D:\User\Android Studio 4.0.1\Applications\SampleApp\app\build\outputs\apk\debug
Now drag the .apk file to upload it anywhere!
For testing it in mobile without connecting USB, you can Gmail yourself by uploading the file through Google Drive. And then downloading the .apk through Gmail in the Mobile Device.
NOTE : the file location I have mentioned in Point 3 is different than yours, because I always keep my projects in D: drive. It would be similar after you go to your application folder (after SampleApp folder).

Cannot update project from terminal in Android

I am developing an Android project. In my project, I need to do OCR. So found this tutorial http://www.codeproject.com/Tips/840623/Android-Character-Recognition. I am trying to follow that tutorial. But I am having problems with set up, especially with updating project from terminal (tess-two folder). See what I have done below.
I downloaded tess-two from this link
https://github.com/rmtheis/tess-two/
Then I installed android NDK to build that project
I set environment variable under PATH
Then I run below command in tess two folder from terminal
ndk-build //this took around 30 minutes. I closed command windows after successful built
Then I run this command
android update project --path C:\tess-two-master\tess-two
The problem starts when I run that command because I cannot run android command from terminal. So I found solution from Stack Overflow. I needed to set ANDROID_HOME and environments variable under PATH. Then I tested "android" command and it is working.
Then I run this command again
android update project --path C:\tess-two-master\tess-two
This time, it is giving me this error
How can I solve this error? Why my update command is not working? What is wrong with my code? I am using Windows 64 OS.
This is another way. Installing using Grandle
I tried another way to install tess-two. I installed using Gradle like this according to documentation. But I cannot access to TessDataManager because it cannot be found in project.
Gradle
dependencies {
compile 'com.rmtheis:tess-two:6.0.2'
}
This is error
As you can see, I cannot access to TessDataManager class. How can I import that class?
The tess-two project has been updated to include a pre-compliled AAR that can be incorporated into your app by editing your app's build.gradle file.
This means that you can skip the steps of importing/compiling the library yourself, and follow the usage instructions on the tess-two project. After following the usage instructions, you'll be able to refer to the tess-two classes -- including the TessBaseAPI class -- directly from your project.

NDK Automatic build in eclipse OSX Invoking autoreconf in build directory:

this time with a droid related question.
Im running Eclipse Helios and Mac OS X 10.6.8
I have been following a book and a few tutorials on building the NDK from both command line and Eclipse.
I am copying the source over there is no static library business. I can compile from the command line fine with the "ndk-build" executable and it works fine.
Though i need to compile inside Eclipse for the reasons i don't need to go into here.
Ive tried 2 techniques and the one i have seen working is to convert my Project to a c++ project and then in Project / Properties / c/c++ Build tab / Build Command i set to ndk-build , this is set to be visible in my path (hence why it compiles when i go to directory and use ndk-build from Terminal)
I then in the C/C++ General tab add the following locations as include directories :
/Users/Me/Code/Android/android-ndk-r7b/toolchains/arm-linux-androideabi-4.4.3/prebuilt/darwin-x86/include
/Users/me/Code/Android/android-ndk-r7b/platforms/android-9/arch-arm/usr/include
/Users/me/Code/Android/android-ndk-r7b/sources/android/native_app_glue
Then when i go to compile i don't get any out put i just get the following error:
Invoking autoreconf in build directory: /Users/me/Code/Android/DroidBlaster
sh -c autoreconf -i
autoreconf: `configure.ac' or `configure.in' is required
Configuration failed with error
Ive tried a few other tutorials but to no avail, if i could award a bounty on this is would as its urgent i get this fixed.
Cheers community :)
NOTE:
Ive worked out that it is using auto tools to build the project where this is incorrect as i should be building with the NDK , getting closer to an answer hopefully. Seems that i cant convert my Android project with CDT to a custom build configuration, might be a bug to do with Eclipse, trying a fresh install
Ok so i worked it out, it was because i was trying to compile using Auto tools when i should have set up the project when i should have been using "Convert to C/C++ project" didn't help though that eclipse installed CDT incorrectly and i had to reinstall to get the right plugins.

eclipse opencv android ndk: The project was not built due to "'NUL' is an invalid name on this platform."

I'm trying to build and run the 'Tutorial 2 Advanced - 1. Add Native OpenCV' tutorial built into the opencv package for android. I wasn't able to use the ndk-build from eclipse following the tutorial from http://opencv.itseez.com/trunk/doc/tutorials/introduction/android_binary_package/android_binary_package.html
But, I built the project from cygwin successfully. But then when trying to run as an android application in Eclipse, it has the error
'Description Resource Path Location Type
The project was not built due to "'NUL' is an invalid name on this platform.". Fix the problem, then try refreshing this project and building it since it may be inconsistent Tutorial 2 Advanced - 1. Add Native OpenCV Unknown Java Problem'
Any help would be much appreciated, thanks
What exactly did you build with Cygwin? I've had an error which prevented me from building from the command prompt but with Cygwin everything works fine.
In Cygwin I first navigate to my project folder:
cd /cygdrive/c/"path to your project folder>"/
then while I'm in the project folder type:
/cygdrive/c/"path to android-ndk-r7b folder"/ndk-build
After using these commands I was able to run the Tutorial 2 Advanced - 1. Add Native OpenCV project. Let me know if this helps you?

Categories

Resources