JNA on Android   3 comments

Samuel Audet, the author of JavaCV and other cool projects you can check out here, has been working on a port of JNA for Android. I haven’t tested it myself yet, but according to the wiki it has reached a functional state. This port would be very useful to simplify the access to native C libraries on the Android platform when coding with the Java SDK.

Currently, access to native libraries from Java code on Android is done with JNI. However, using JNI can be somewhat difficult and requires writing glue C/C++ code. JNA provides a simpler alternative to JNI, since it only requires Java code, although it comes with a performance cost:

The calling overhead for a single native call using JNA interface mapping can be an order of magnitude (~10X) greater time than equivalent custom JNI

(from the JNA wiki). But this disadvantage is not very relevant in cases where the calling time of the native function is small compared with its execution time. Also, JNA provides a direct mapping mapping method that improves performance significantly.

A number of projects that provide Java access to large C libraries through JNA are available: JavaCV, GStreamer-java, Nativelibs4Java, Java-Kinect, and more will probably come along.

Given the importance of the Java SDK on the Android platform, makes sense to have a version of JNA for it. Initial discussions on the google code site of the Android project indicated that priority to implement this port by the Android engineers was low, apparently because of performance concerns. With this initial release of JNA for Android by Samuel, it would be interesting to see how this evolves and if it makes possible to access libraries such as GStreamer (some relevant links).

About these ads

Posted December 7, 2010 by ac in Programming

Tagged with , , , , ,

3 responses to “JNA on Android

Subscribe to comments with RSS.

  1. What’s the status on jna on android, and gstreamer-java on android?
    Thanks,
    Srini

    • Hello, the person who was working on JNA for Android, Samuel Audet, marked the project as deprecated. The comments in the page of the project give an idea of the developments that took place during the last months. It seems he is currently developing an alternative to JNA, called JavaCPP, which you can access here. In any case, Samuel’s Android patch for JNA is still available (although it hasn’t been included in the source trunk of JNA).

      Summarizing, it is not clear to me at this point what would be the best alternative to have gstreamer-java ported over to Android. Right now I’m busy with other projects, so I had to put this work in the to-do list for a little while. Hopefully I will come back to it at some point during in the next few months.

      I hope this information is useful.

  2. Useful information, if somewhat disheartening…

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 60 other followers

%d bloggers like this: