python to android convertion with Kivy - android

I have a Python3 desktop application which I want to convert to an android apk. I saw that Kivy module exists and might be able to pull this off, but I am concerned about it's ability to make the apk work just like the python code. I use many different modules like PIL, opencv, pyserial, threading, watchdog, file_read_backwards etc).
Is this possible or I am asking for too much? And if it is, how can I change/handle for which android version it will the apk be?

threading is in the stdlib, so you have it
file_read_backwards is pure python and doesn't seem to require anything (as per setup.py) although the requirements_dev.txt lists a lot more things, so i'm not sure
PIL has a recipe (https://github.com/kivy/python-for-android/blob/master/pythonforandroid/recipes/pil/init.py), and there is also now a Pillow recipe, which is probably better to use (https://github.com/kivy/python-for-android/blob/master/pythonforandroid/recipes/Pillow/init.py) so that seems fine
pyserial is pure python, and i think i remember people having success with serial over usb on android, though i didn't try myself, it might require a device able to be an usb host and not just client, but i don't know much about that.
opencv has a recipe, it might be a more touchy one, as it hasn't been touched in years (aside from some cosmetic fixes), and i think i've seen people having issues with it, but i'd say it's worth a shot.
I'd say, it's certainly worth a shot, before converting any of your code, try just building a hello world application with kivy for android, then redo the build but adding your dependencies to the requirements one by one, and see if you can solve it or find help when it doesn't, if all go well, then look into porting your code, which is the part where the success will certainly depend more on you than on what kivy/python-for-android can do.

Related

Tensorflow on Android via Kivy

I found this answer that brought me to the idea instead of using the compiled tensorflow graph you might be able to use kivy on your Android phone. That way you could directly talk to the tensorflow graph using python-for-android.
A possible advantage would be to train/adapt the model on the fly. As far as I know otherwise you can only use the final trained model (but this is currently unanswered on stackoverflow). Also cross compiling to Windows Phone might be possible what currently isn't (see here).
I don't know the technical limitations. Anyone can confirm that this is possible and maybe what would be neccessary?
Although WinPhones could be a possibility in the future, there's basically a situation where almost no-one cares as there isn't really much interest about porting it. However, there's a thing in progress about using angle for translating openGL to DirectX, so it could be possible later. There's still this funny app packaging though, so it'll eat a lot of time.
Yet I think it might be possible to use those unofficial converters APK -> WinPhone app. Re TensorFlow: to me it looks like only a recipe is missing so try write one. :P

Pros and Cons for Haxe and Kivy

I'm looking to develop an application for iOS, Android, Windows Phone and for Desktop no matter if it's web or standalone. Does anyone have experience with Haxe + NME or Kivy that they can share in detail?
I've been looking for something that can deploy to all platforms and these are the 2 best options I seem to have found. I'm not looking to make a game though. It's more like an app with a lot of touch listeners on images. Touch image then hide this, create that, and do a lot of math behind the scenes. I do however need a pathfinding library but pretty much all engines I've worked in had the A-star pathfinding library. I also need a slideView library so users can swap pages like they do on their smartphone desktop. Any information you can share on the following topic is greatly appreciated. Thanks in advance for reading and for any help provided. Sorry for the trouble
no experience with Haxe here, but I can answer for Kivy:
First, windows phone is currently unsupported, to my knowledge, no one attempted any port, it's probably doable, but it doesn't exist yet, and no core contributor have a windows phone device, so until that changes, or someone with that motivation comes in, there is low probability that it will happen.
For your interactive needs, Kivy would fit the bill pretty easily, being really focused on making touch handling per-widget easy to define. We don't have much information about your math needs, if they are heavy, you'll probably want something like numpy to be usable behind the scene, and/or use threads to do the heavy lifting without blocking the application, this can totally be done with Kivy, so i see no particular issue there. For A*, there isn't any implementation directly inside kivy, but you should be able to use a python implementation (there are dozens out there), if your needs on this side require more performance, you can cythonize it to increase performances, or use a C implementation compiled for each target.
Hope this helps.
long time Haxe user here, though personally I mostly use Haxe for web-app projects, not NME as much. Until recently NME's main focus has been (far and away) gaming. There has been a few recent efforts to create nice UI toolkits building on NME's cross platform strengths:
https://github.com/RealyUniqueName/StablexUI - Demo (works on HTML5, flash, native desktop&mobile)
https://github.com/ianharrigan/haxeui
but they are very recent additions, so if you're looking for a tried and tested solution Kivy (never heard of it before, but looks cool!) looks like it has a bit more maturity and a bit more polish going for it.
In terms of performance and overall reliability, Haxe/NME is great, but it's getting those native-feeling UI widgets that will be your pain point. Other than that though, it's an amazing language to work with :) Python's pretty good as well though... each to their own!
At the time of writing, people are experimenting with using Native UI (there is a talk at the upcoming conference about an Objective C target, and the Java and C# targets are becoming more mature, so there are your 3 main mobile platforms covered) so that could be an option if you want native ui components, though it's not ready yet, this is me just hoping that it might become reality over the next year or so :)
Good luck with your project either way! If you do choose to go with Haxe/NME, be sure to ask questions (either here, the NME forums, or the Haxe mailing list) so that people can help you on your way.

Python for IOS or Android

I have been looking at the different packages for python on android and IOS as i am going to be upgrading my phone soon.
However, i dont know which OS to go with. For android they have the SL4A package, but for IOS they have their equivilent. However, im stuck on which to go for. Does anyone have any suggestions for this?
I know its kind of a stupid question, however im just getting into mobile development since they allowed scripting languages on the mobile platform.
The python support for Android is pretty good, but still under development. You can do things that a scripting language can but not the stuff that Python as a OO language can.
Example:- When you go through the api reference here, you can see that one can write scripts to do basic to complex tasks, but, in a restrictive way. You can never build full blown apps, and even if you do, it will always be slow because the SLA4 is just another layer on top of few other layers in the Android hierarchy. There have been a lot of fun stuff that has been done using Python scripting, example: http://www.wired.com/gadgetlab/2010/07/nexus-one-phone-rides-a-rocket-up-28000-feet/#ixzz0v7LFT7ay (A bit over-board and crazy, but awesome nonetheless.)
I don't have much experience on an IPhone to pass on such comments. But, an IPhone is expensive. You can always get a used Nexus phone and do all kinds of Python hacking/scripting. All depends on your budget and your need.
That is all.
I had been on the lookut for Python on iOS for sometime. About 2-months ago, one one released to the iTunes app store -- http://pythonforios.com/ and it is fantastic! It includes the complete set of Python 2.7.2 documentation -- which alone is worth the $3 price.
It's a bit of a challenge to code any serious apps (which I suspect is the result of the developer having to comply w/ Apple's app guidelines), but it is a perfect place to test ideas from a train or airport (when you are without a laptop).
1 caveat -- I've only tried it on an iPad. It could be a bit cramped screen real-estate on an iphone.
Pythonista is an excellent alternative for the iOS platform - here's a nice article on it. And this one details how you can achieve workflow automation on the iPAD.

Port possible? (grim fandandroido)

The dream is to run Grim fandango on my android,
And i stumbled onto 'residual' (http://residual.sourceforge.net/ it's a c++ application) and someone who made it to run on his nokia n900 (http://www.youtube.com/watch?v=TO9a5nTMHYI).
So for the question, would this be possible for android? My initial thought was the support debian and ubuntu and my android is faster then the n900, why not?
So before i spend days/weeks learning and getting it to work on my android,
I thought it might be a good idea to ask people who actually know about these things if its even possible.
And maybe how much work it really would be, in my head it's currently only:
make allot of Android.mk's
try to compile and fix errors still it works.
Which (if i don't get to many errors) doesn't sound to hard.
Any thoughts are welcome,
Thanks for reading!
I'd say your goal is totally feasible.
Residual seems to rely on standard C++ libraries, plus OpenGL and SDL. For the latter, there are actually several SDL Android ports out there you can take advantage of.
Somebody familiar with Android and the NDK could probably get Residual to a somewhat playable state in a few days (a proper port would take much longer ofc). If you're new to the platform however, you should be prepared to spend several weeks learning the basics of native application development in Android before tackling the project.

A non-programmers guide to programming

Okay so I am a very low level programmer and happy to admit it. I can write simple programs things like VB and python etc given the basic syntax. I want to write simple programs for android, for instance a calculator that handles feet and inches and a program that simply searches a database of products and tells me the details of them. Is there a simple solution where I can drag and drop some buttons and text boxes and execute code or do I have to learn the whole gui drawing code and start from scratch? If I do have to start from scratch is there a book out there that doesn't assume that I know any of the advanced coding techniques or do I have to learn the whole language and then learn the SDK? I want to be able to write a program quick and dirty, here are the variables here's the formula, do your thing...
Android App Inventor.
The problem with this approach is that you'll learn how to make apps in App Inventor, but not learn how to program Java nor how to program Android. It may be useful as a first stepping stone though, or if you really don't want to get your hands too dirty.
Android App Inventor can do exactly what you want. I've done something similar with it.
One month and a half ago, it took some of my students (and some other random people) about two weeks to get the initial invite (once they had put themselves on the general waiting list). Since the form for the waiting list is still in effect, I assume it will take around the same waiting time in your case, or may be even less.
A couple of caveats thought: You need an Android phone to run your 'Android App Inventor' App (it won't run in the emulator). Android App Inventor doesn't give you access to the generated code (they have no plans to, besides they're not using java for the generated code anyway). App Inventor won't let you publish on the Market (although, they do have plans to add that capability, for now if you want your friends to install your app, it can give you a QRcode for it, or give you the apk file to share with them).
While you're waiting for your invite, I'd suggest you try out Android Scripting
http://code.google.com/p/android-scripting/
Scan the QRcode on that page (it's not on the Market yet). Install the SL4A app. Once SL4A is running, press on the menu key > select 'Add' > select Python. Once that's running, I recommend you run the test.py to see what kind of GUI intents can be launched directly from your phone python shell. The SL4A project is still very much alpha quality, but I'd say it's worth playing around with (especially in Python, since Python seems to be currently the most mature scripting environment supported on there, it actually supports a zillion other scripting languages).
Another thing you can do, from the Market this time, is to download the 'AndroidShell Lite' app. run the app, press the 'Local Console' button, and play around with that. I suspect that AndroidShell is using a version of the SL4A, but unlike SLA4, it can not be run in the emulator, the code doesn't seem to be open source, it doesn't support python (only beanshell which is just as easy actually), but it has much better documentation at least. That's why I'm recommending that you try out both 'AndroidShell Lite' and SL4A. Each has different strengths.
I believe App Inventor is what you are looking for. It is not designed for complex apps but can be helpfull for simple apps.
https://www.google.com/accounts/ServiceLogin?service=youngandroid&passive=true&nui=1&continue=http://appinventor.googlelabs.com/ode/Ya.html&followup=http://appinventor.googlelabs.com/ode/Ya.html
regards.
I will suggest you do the following:
1. Improve your JAVA programming skill. Reading material: "Think In Java"
2. Improve basic Android programming skill: any entry level android book
Make sure when you go through the material,
do your best to design and implement some useful projects, and publish to the market if possible.

Categories

Resources