Build Tensorflow Demo For Android - android

I am following this link to build the Android App:
https://github.com/tensorflow/tensorflow/blob/master/tensorflow/examples/android/README.md
I am using Window Subsystem Linux command to do this project.
I have installed Bazel already.
I know that after I install Bazel, and before I run the build command, I need to change the WORKSPACE file with correct NDK/ADK file address and go to the workspace root and run "touch WORKSPACE". Here are the codes i ran:
'tensorflow folder sits inside 'C:\Users\username\AppData\Local\lxss\home\alexluk\tensorflow
cd /home/username/tensorflow
touch WORKSPACE
However, when i ran "touch WORKSPACE", here is the error i got:
touch: cannont touch 'WORKSPACE': onput/output error
It would be great if anyone can let me know where went wrong and what should I do.

For future people that might need help with this:
It looks like Windows Subsystem Linux is very particular about not editing the Linux files from Windows. See this blog post:
DO NOT, under ANY circumstances, create and/or modify Linux files using Windows apps, tools, scripts, consoles, etc.
At this point, you can probably remove the file using Windows and then recreate it using Linux.

Related

How to use Android Studio with WSL (bash) as your shell Terminal?

Is it possible to use Android Studio and configure Windows Subsystem for Linux as a Terminal? I really don't like to work with Windows cmd.exe, but when I try to switch to bash.exe, which seems to work, it cannot build the project because there are missing e.g. Android/sdk/build-tools/27.0.3/aidl'.
This file is there, but it is with .exe suffix as it was downloaded for Windows. Any workaround to use *unix like bash for Terminal in Android Studio while being on Windows 10?
Yes, it is possible. I'm doing it right now. I have an Ubuntu app as WSL and figured out that it's accessible at C:\Windows\System32\bash.exe
So, open Android Studio and navigate to File -> Settings -> Tools -> Terminal. There fill Shell paht with C:\Windows\System32\bash.exe and voilĂ !
Now, when you open a new terminal it will use the WSL you have installed in your machine.
I'm using Android Studio 4.0.1.
I'm setting this up right now and hit your question from Google looking for advice. So with that caveat, let me explain what I did to get it running and if you have follow up questions we may need to experiment together to find the answers.
First, I installed VcXserv: https://sourceforge.net/projects/vcxsrv/. This X Server for windows allows you to run graphical linux applications in WSL. You'll just need to export the display variable in your ~/.bashrc since that isn't done normally in WSL:
$ echo "export DISPLAY=:0" >> ~/.bashrc
Then you have to run XLaunch from the start menu. It takes you through the config dialogs (just choose the defaults) and it puts an icon in the notification area you can check to make sure it's running.
Then, you want to download the Linux version of Android Studio 3.1. Extract it into the WSL filesystem somewhere (I used ~/apps). Then from your bash shell you can run android-studio/bin/studio.sh and the window will appear and begin the unboxing dialogs.
This is as far as I've gotten, right now it's downloading the SDK. I still am not sure how adb over usb is going to work or tested the emulator. I'll update this if I learn more.
Update unfortunately, VcXserv is crashing when the main Android Studio window launches. I'm going to file a bug report on it and try some other X servers if I have time later.

Error building Android project in Cordova

I am new to Cordova and I am trying to build my project, which was previously working. I believe I have a bug. I am not very experienced with the terminal so I don't know how to resolve this. I have tried uninstalling and reinstalling cordova, as well as updating it with no success. Here is my error:
[Error: ANDROID_HOME is not set and "android" command not in your PATH. You must fulfill at least one of these conditions.]
ERROR building one of the platforms: Error: /Users/joshuaoconnor/Desktop/PBBars/platforms/android/cordova/build: Command failed with exit code 2
You may not have the required environment or OS to build this project
Error: /Users/joshuaoconnor/Desktop/PBBars/platforms/android/cordova/build: Command failed with exit code 2
at ChildProcess.whenDone (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:134:23)
at ChildProcess.emit (events.js:110:17)
at maybeClose (child_process.js:1015:16)
at Process.ChildProcess._handle.onexit (child_process.js:1087:5)
and here is the full image of the terminal
Your running in a standard "beginners" issue by using cordova or phonegap - but no problem, we are here to help you ;-)
The Terminal tells you, that:
ANDROID_HOME is not set and "android" command not in your PATH.
So, you $PATH is a SystemVariable which "saves" pathes to important files and folders. All files, which are part of the SystemVariable $PATH can be called via your Terminal. So because i don't know, which OS you are using, i'm going to post two solutions. One for each, mac and windows.
Before you start: The PATH is a SystemVariable which is needed as it is. Another folder can be added by a : which seperates the single folders and pathes inside your PATH. If you do anything wrong there, your system may never work correct again without reinstalling it - be carefull and do not delete any of the PATHs content which is already there.
What do i need in my Path? (especially for Cordova/PhoneGap now)
So you need three things in your Path:
%ANDROID_HOME%
tools
platform-tools
How can i see my actual $PATH?
echo $PATH on a mac
echo %PATH% on windows
How to set up the PATH Variable on Windows
Select your Computer from the Start Menu.
From the Contextmenu select System properties.
After that select the advanced tab.
In that section you click on Environment Variables.
So in the section System variables you're going to find the Path which can be edited over there.
How to set up the PATH Variable on Mac OS X Yosemite
Open your terminal and go on like this:
vi $HOME/.bash_profile
Add a line there with this content:
export PATH=$PATH:new/dir1/:dir2:/dir/path/new
This changes will be loaded after a reboot - to apply them immediatly after you changed it, save and close your file and type source $HOME/.bash_profile.
If you have any further questions, let me know - i'm going to edit my answer than.
By the way: There is a great Documentation on how to install Android-Platform on Windows machines. It can be found here, inside the Apache Cordova Docs -> Android - Shell-Tools Guide
Look for the local.properties file and add the correct path to your sdk sdk.dir=/home/somewhere/android-sdk/sdk
I would suggest to generate the project using cordova but build it using Android Studio, since you will probably want to tune one or two things on your android project anyway.
EDITED:
It seems you are on windows, so a quick way would be to set an Environment Variable called ANDROID_HOME pointing to the directory where you downloaded the android sdk as per the Cordova documentation
Either that or the steps stated on the documentation:
To modify the PATH environment on Windows 7:
Click on the Start menu in the lower-left corner of the desktop,
right-click on Computer, then select Properties.
Select Advanced System Settings in the column on the left.
In the resulting dialog box, press Environment Variables.
Select the PATH variable and press Edit.
Append the following to the PATH based on where you installed the SDK,
for example:
;C:\Development\adt-bundle\sdk\platform-tools;C:\Development\adt-bundle\sdk\tools
I was able to figure an answer out on my own. Coming from a complete beginner with no experience with bash profile, I was lost with your instructions (no offense). To fix this issue, learn how to edit your PATH environment variables. I used this tutorial (http://hathaway.cc/post/69201163472/how-to-edit-your-path-environment-variables-on-mac) which showed how to do it with textedit. After I learned how to edit my PATH variables, I added
export ANDROID_TOOLS="/Users/joshuaoconnor/Documents/sdk/tools"
export ANDROID_PLATFORM_TOOLS="/Users/joshuaoconnor/Documents/sdk/platform-tools"
to my BASH profile. Sithys and Logains answers did not work for me.

Installing SDK and NDK to start coding android apps with python

http://python-for-android.readthedocs.org/en/latest/toolchain/#introduction
Please do not mind because this not really related to SO. I aint getting replies in askubuntu that is why I am posting this question. Please do answer. it will be much appreciated.
refer the link above, I downloaded the SDK and the NDK, i run the SDK manager and I installed the required files. This is enough as a platform right? or I need to download ADT or eclipse?
I installed cython also as given in the doc. What I want to know it, if I install eclipse, which version should I first download? because there is no eclipse in particular for python.
Secondly, after setting up any platform(in my case, its just SDK manager, not eclipse) it says
'after installing them export both installation path, NDK version and API to use' what does it even mean?
I remember, before installing or running sdk manager, I opened .bashrc file, put up 2 lines,
export path=$path:......android-sdk
export path=$path........android-ndk
saved it.
I do not know whether the SDK manager started working because of that, but it works and my emulator also works after creating a vew avd.
I am totally stuck at the exporting of installation paths, versions and apis. Where do I export them to?
And if you go futher down, you can also see 'configure youre path to add android binary:' what does this mean? I have a ubunu 12.04, I need to set environment variables?
Then further down, it says 'USAGE',
./distribute.sh -m "kivy"
When i run it, it says distribute : no file or directory. Well, I have just downloaded kivy and extracted I havnt done anything more to it. What am I supposed to do. Please help me here. I really need it. Thank you
I can't give all the details on the individual bits of the build process you might have done wrong, but rather than doing things this way you can use the buildozer tool. If you follow the instructions to install it, it automatically downloads and links all the dependencies (including sdk/ndk/python-for-android/python/kivy), reducing the build process for a kivy app to a single command.
Then further down, it says 'USAGE', ./distribute.sh -m "kivy"
When i run it, it says distribute : no file or directory. Well, I have just downloaded kivy and extracted I havnt done anything more to it.
You would need to run that command from within the directory where you unpacked python-for-android. There would be a file in that directory called 'distribute.sh'.
Also, you don't need to download kivy yourself, python-for-android does this automatically as part of its distribute process. You do need to install your own version of kivy to use it locally, which I assume you've already done?
I assume you are making a kivy app? That is what these instructions are designed for.

Android: NDK setup in windows

I've been planned to develop an Augmented_Reality(AR) application in an android. So I've gone through various of contribution installing a libraries in eclipse(IDE) like artool,qcar sdk and so on, then I've found that NDK installation should be made before getting into artool kit or qcar sdk So I started to install NDK and progressed as they said in below link:
http://mindtherobot.com/blog/452/android-beginners-ndk-setup-step-by-step/
after doing 'Cygwin' installation they wrote to write 'make -v' in console. Hhen I did I got 'GNU make 3.82.90' but theirs is 'GNU make3.81' as:
where it wasn't as same mine. I know that am using updated cygwin but my problem is I can't able to get .so file as they mentioned accordingly in eclipse. So could you tell me, where I made junk and how can I recover to run AR application in eclipse. Thank you!
actually if you are using window then you do not need to install cygwin. you can also run your project with cmd prompt with following command
start>cmd>cd C:\demoworkspace\testingndk>enter
in Command prompt This is my directory where my project is located with project name. after this
run the ndk address like
C:\demoworkspace\testingndk>C:\ndk-path\ndk-build
ndk-path is directory name where your ndk is located. this will automatically pick your jni c file.
for ndk related query please write me at kdeepak5477#gmail.com
When you are installing cygwin (I used a wizard) make sure you open the DEVEL tree and install MAKE (binary is fine, no need for source).
I also get all the GCC and MINGW stuff just in case.
Perhaps uninstall cygwin, and reinstall using the wizard and ensure MAKE is selected from DEVEL tree.

eclipse won't create adt project due to 'access denied'

I installed JavaEE, JDK, Eclipse 3.5.x (Galileo), the Android Starter SDK, and the current ADT all with no problems. However, when I try to walk through the 'Hello Android' tutorial, I bring up the New Android Project wizard, fill it in and hit 'Finish'.
After a moment, it comes back with a message saying there was a problem at path X:\so and so\ (access denied).
Things to note:
-Running Windows 7 Home Premium 64-bit
-Quadcore Pentium with 8GB RAM, 8TB NAS
-I am an Administrator
-I have also tried this by activating the full (hidden) Administrator profile
-I have reinstalled everything 8 or 9 times
-I have changed ownership & permissions all over the place
-I have launched eclipse in 'Run as Administrator' Mode
-I have installed Everything as 32-bit, as others have done this successfully
Eclipse creates the folder it's having a problem with, but then cannot work with the .project file it creates (access denied). It then can't save anything so there is nothing but an empty folder 'Hello_Android' on the left within Eclipse.
Anybody have any clues about what is going on-- I'm frustrated. I want to get into this, and I've looked EVERYWHERE on the net trying to crack this nut.... but I need help.
-J
Hmmm. Interesting.
I would double-check permissions on the folder X:\so and so\ and ensure that the Administrators group and/or your account has full control.
Have you tried creating the project outside of the users or systems environment? You know in c:\myprojects
Windows7 and creating/saving files in program files or documents can be a PITA.
Turned out to be a bug with how eclipse is written. I've developed a workaround.
The problem is that eclipse can't write to hidden files, unhide them and it should work.

Categories

Resources