Difference between Kivy and PY4A
Asked Answered
C

4

29

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?

Cochineal answered 28/8, 2013 at 2:32 Comment(1)
"Kivy - Open source Python library for rapid development of applications that make use of innovative user interfaces, such as multi-touch apps." vs "Scripting Layer for Android (SL4A) brings scripting languages to Android by allowing you to edit and execute scripts and interactive interpreters directly on the Android device." I cannot find anything in common between the two...Moolah
C
25

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.

Camilia answered 28/8, 2013 at 10:28 Comment(2)
You can do GUIs on SL4A, native and webviews. The kivy guys misrepresent SL4A at cons and stuff, so you have to expect some confusion.Defrock
Sorry for the mistake, my misconception was from reading the SL4A documentation which mostly talks about the scripting possibilities.Camilia
L
10

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
Lattimer answered 3/7, 2014 at 13:16 Comment(0)
R
1

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

Reciprocate answered 20/1, 2014 at 8:51 Comment(0)
W
0

In addition to the answers here, I'd add the fork of the original Py4A which seems to be actively developed: https://github.com/kuri65536/sl4a

I can't vouch for the quality or the ease of use. There are .apks to install so it seems fairly straightforward.

Washery answered 21/1, 2018 at 16:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.