Max Max - 4 months ago 29
Java Question

How can I bundle a .so file in a jar?

I'm currently working on a java library (binding) which uses some own written native code. This native code is compiled as a

.so
file for multiple architectures (arm-v7, i686, x86-64, etc).

I know in android you have to create a folder called
jniLibs
with subfolders for each architecture containing the proper
.so
file. Then with an
Android.mk
file and
System.loadLibrary
I can include these files into my code.

However, I have no clue how to include these
.so
files in a normal java project/library. I have read online that
System.loadLibrary
only works for looking through normal files (and not necessarily project files).

Answer

You can't have anything other than code in an android .jar file, however, you can have resources in an .aar file.

Android Archive Library (aar) vs standard jar

You will find that the .aar for your library is the redistributable/reusable compiled version of your library.

Comments