Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between Kivy and PY4A

I'm new to android development, and I have had some experience with Java, C#, Python, etc. Python being my favourite, I'd like to code Android app with it.
Then I saw this question:
Is there a way to run Python on Android?
The most voted answers mentioned Kivy and ASE(which is now SL4A and includes PY4A).
However, after some googling, I wasn't able to find any useful info about the difference between Kivy and PY4A. Searching for difference between Kivy and SL4A was fruitless, too.

So, as for Kivy and PY4A,
can someone explain, in easy terms:
- What are the similarity and difference between them?
- What are their good and bad parts?
- Are there any other good alternatives?

like image 433
octref Avatar asked Aug 28 '13 02:08

octref


People also ask

Is kivy slow?

Many people state that kivy is slow. While this may be true it is mostly due to that python is slow to run on android devices. Thus it is in the programmer's hands to properly optimize their code so as to create a performant application.

Is kivy safe?

Is Kivy safe to use? The python package Kivy was scanned for known vulnerabilities and missing license, and no issues were found. Thus the package was deemed as safe to use.


3 Answers

Confusingly, there are two projects called 'python for android'.

SL4A lets you run python scripts on android. Their PY4A is a step in their toolchain, but I don't know much about it. I understand there is some integration with android apis (you can use some hardware etc.), but limitations in how to run the programs (they aren't full apps, no gui etc.). This is stuff I infer from seeing other posts, I haven't tried it, don't take my word on the details. (Edit: actually it seems there is some ability to package apks and multiple ways to create a gui, I don't know the details)

Kivy is a graphical framework that supports many operating systems (linux, windows, osx, android, ios, maybe more already). You use it to build python guis. The kivy project also started their own python-for-android project which provides ways to compile the python interpreter for android and to package it as an actual android app (including java api integration with pyjnius etc.). Kivy is well integrated with it so that you can easily compile a python gui app for android, though I don't think this python-for-android is limited to kivy apps.

So, they are completely different projects that happen to have a component with the same name. SL4A is for running python scripts on android, I don't know much about its limitations or details. Kivy is a python graphical framework (not limited to android) that can be compiled via its own different python-for-android project to fully integrated gui android apps.

You can see (for instance) kivy showcase for examples of some simple kivy capabilities, or flat jewels for an example of a simple game made in kivy. These are just examples, a lot more is possible.

like image 111
inclement Avatar answered Oct 21 '22 03:10

inclement


I've found this very useful (and recent):

Embedding Python in Android (Tutorial series)

http://techventura.wordpress.com/2014/04/21/embedding-python-in-android-series/

It describes how to embed Python in an Android app, using the Kivy-related Python-for-Android, but not Kivy itself (which isn't really described in Kivy's nor Python-for-Android's documentation, as far as I found), which is useful in various scenarios (e.g. existing Java app, using native GUI directly, etc.)

Since Kivy's Python-for-Android is more actively developed than SL4A(ASE)'s Py4A, it seems to me the way to go.

(I think it would be very relevant also, and probably more appropriate, to Is there a way to run Python on Android?, but to answer requires more reputation than I currently have.)

To the point of the original question: the most relevant difference I see between Kivy's Python-for-Android and SL4A(ASE)'s Py4A is that the latter is still today offered as "alpha quality", while the former seems to be far more active. Of course if you take Kivy as a whole, it's a cross-platform GUI library.

Also, the results of my research on the various solutions:

  • Google's Py4A + SL4A(ASE) : used but alpha quality, not actively developed
  • Kivy:
    • offers Python-for-Android, to call python code from Java
    • offers Pyjnius, to call Java code from python
    • seems to be actively developed
    • there's the tutorial I linked above to embed into Java Android app
    • if interested, the cross-platform GUI (Kivy itself)
  • QPython:
    • primarily an interactive environment to launch python scripts on Android
    • based on Py4A, but Pyjnius (see above) is said to be usable
    • embedding into a Java app is available, but somewhat limited: a Python job must be started with an Intent, and results are gathered from the stdout; that means more separation that could be desirable in some scenarios, I think.
  • python.org: no mention at all of Android
like image 10
GozzoMan Avatar answered Oct 21 '22 04:10

GozzoMan


Have you tried QPython ? It's a new python for android instance which offers more functions.

like image 1
River Avatar answered Oct 21 '22 03:10

River