4 ms·
Some years ago I tried to use python-for-android, but found it too much of a burden to do what I wanted, which was just to simply integrate existing python code
by jventura 10y ago
Some years ago I tried to use python-for-android, but found it too much of a burden to do what I wanted, which was just to simply integrate existing python code in native android apps (with Java). Don't know how much has changed since then, but python-for-android's bootstrap used pygame and pysdl to start an opengl scene, where you would have completely non-native widgets.
I rolled my own solution [0] which uses crystax distribution's of CPython for android (Python 3.5), and I did a very simple JNI bridge between java and cpython using an RPC-like mechanism over json. Basically, on the java side you call a function and pass the arguments [1], and on the python side you "route" it to your own functions [2]. I think all pybridge's code is very very simple for those who understand a bit of Java, a bit of C and a bit of Python, and I explain in the readme how everything works, including which classes/files are relevant.
I have an app where I use this [3], and although it hasn't earn me much money so far (~20 downloads, 110€), it is rated 4.7 in the play store, so the performance of accessing python functions on android is not bad at all..
[0] https://github.com/joaoventura/pybridge https://github.com/joaoventura/pybridge
[1] https://goo.gl/sw4JLt https://goo.gl/sw4JLt
[2] https://goo.gl/17SlVb https://goo.gl/17SlVb
[3] https://play.google.com/store/apps/details?id=com.flatangle.charts https://play.google.com/store/apps/details?id=com.flatangle....
- inclemnet 10y agoWe've actually completely rewritten python-for-android since then, it now supports multiple bootstraps and is not tied to Kivy at all, and it should be relatively easy to use the python distribution in a native app (although this could be streamlined). CrystaX's support is great though, and actually python-for-android uses this for Python 3 builds.
- on_and_off 10y agoI looked at the app, as far as I can tell, it seems fairly basic. Why use python for this ?
- jventura 10y agoBecause I already had a lot of code doing a lot of things in Python (https://github.com/flatangle/flatlib/ https://github.com/flatangle/flatlib/)..