Native JNI Library Support?

Falco32

Member
Licensed User
Longtime User
I have a question. I have created a java library project wich includes a JNI
library libxxx.so but when i compile this project the library file is
removed from package. does the new compiler accept the JNI libs folder ?
in a custom library project ?


Regards Falco32
 

warwound

Expert
Licensed User
Longtime User
Hi.

There's a little info here:
http://www.b4x.com/forum/bugs-wishlist/21726-wish-compiler-support-so-library-files.html

Basically you need to ensure that when you compile your library in Eclipse that the library jar contains a folder lib and that your .so file(s) are within that lib folder.

When you compile your B4A app, the .so file(s) should now get added to the APK and when the APK is installed the device will automatically install the .so file(s) to the internal memory where your app is installed.

Martin.
 
Upvote 0

Falco32

Member
Licensed User
Longtime User
Thanks !!!

Folder lib not libs ???
the result in eclipse are multiple subfolders(armabi armabi-v7) in the folder libs.
what should i do with this ?

can i load the so files with System.LoadLibrary("libxx") ?
 
Upvote 0

warwound

Expert
Licensed User
Longtime User
the result in eclipse are multiple subfolders(armabi armabi-v7) in the folder libs.

That's ok.

The .so file in the armabi folder is (i think) for devices that have no hardware floating point unit - that's generally old or low end devices.

armabi-v7 contains an .so file that is compiled to make use of a hardware floating point unit (ie it's faster than non-floating point unit).

Android will, when you install your app, decide whether to use the .so file from armabi or armabi-v7 based on the device capabilities - it's all handled automatically.

Some libraries even have a x86 folder with a .so file compiled for Android devices that have x86 CPU, again the Android installation process handles which .so file gets used on the device.

Martin.
 
Upvote 0

Falco32

Member
Licensed User
Longtime User
thx a lot guys!

it works great!!!
a next question. in this folder in my project is as result also the standalone binary xxx.bin. Is there any way to load this binary from lib folder ?
I would like to start a binary from libs folder because i need root rights.
Is it possible ? And when so can you give me a short two liner how can i start this from the java lib ?


Thanks so much!!!
 
Upvote 0
Top