On Thu, Apr 28, 2016 at 11:09:52AM +0200, Xavier de Gaye wrote:
On 04/28/2016 03:01 AM, Russell Keith-Magee wrote:
(Apologies for the personal repost - I forgot to reply-all on the first attempt)

Hi Xavier,

Great stuff!

I’ve got a question about your experience integrating with the native Android 
platform APIs.

Getting CPython compiled as a native binary library is a huge step, but my 
experience has been that bridging between binary libraries and the Java/Dalvik 
APIs is a painful process - JNI *exists*, but
it’s *really* slow, and has some pretty harsh limitations (like the 
kernel-imposed JNI reference count limit).

For some applications, this won’t matter - for example, if you’re treating the 
android device as a low power server, something that is terminal only isn’t a 
problem. However, if you want to write a
native app, then you need to be able to create an Activity, with a View, put a 
Button on it, and a Layout, and so on. Have you done any exploration of the 
binding to these native APIs?


A first-class citizen java application embeds python using JNI. The embedded
python accesses the android API by importing and invoking methods of an
android.py module.  The android.py module maps those API requests to json RPC
calls that are sent to another java application so that they may be processed
and their results returned.  This is the design of Scripting Layer for Android
(SL4A) [1], a languishing project.

IMHO you should define what 'slow' means, slow for a gaming application, for
tracking the smartphone accelerometer or for a pyephem based application that
brings the ephemeresis of stars and planets at your finger tip :)

Xavier

[1] https://github.com/damonkohler/sl4a

You may be interested in pyjnius[1], which, if not working around the JNI limitations (speed being one, but other JNI limitations for using the Android API is the inhability to extend java classes), makes using it with python a lot easier, by using Java introspection capabilities, it may not be the best answer if speed is the most important criteria, but i would advocate for reconsidering using Python on Android if that's the case.

[1] https://github.com/kivy/pyjnius
_______________________________________________
Mobile-sig mailing list
[email protected]
https://mail.python.org/mailman/listinfo/mobile-sig

Reply via email to