1

This might be a really rookie question, but I'm writing an Android app that needs to use a .so library written in C++. The .so is made up of several classes, and is in generic C++, not JNI.

Is there a way to call the C++ functions from the Android Java app, other than JNI? Everything I've seen about JNI suggests that you have to rewrite the native code to be JNI-specific, and that is really damn inconvenient if you're only given a .so.

What alternative methods exist for calling native functions from a java application in Android 4.0.3? How simple would it be to write a small JNI-C++ program that calls the C++ functions, and can then be called from Java?

Is there anything in Eclipse that will simplify the process?

I probably shouldn't be surprised that there isn't a more elegant solution.

eskimo9
  • 753
  • 10
  • 24

2 Answers2

0

I do not believe there is a more elegant solution than the one you suggested of writing a JNI wrapper for the library. It is probably not a good idea anyway as you should be compiling separate versions of all your native code for each architecture you want to support. Just attaching to a compiled library means you are hamstrung by it's architecture.

Bostwickenator
  • 380
  • 2
  • 11
  • OK so given the complexity of my native library (there are 5 classes that interface with each other, but the user-end only needs to instantiate one class and call about a dozen functions), it looks like I should use SWIG. Does anyone know of a good ground-up SWIG tutorial using a Windows system to compile for Android? Yes, it would be easier to compile on Linux, but not an option here. – eskimo9 Apr 17 '12 at 00:02
0

This isn't Android-specific, but you should take a look at Java Native Access (JNA). It lets you access native code using libffi (without using JNI).