I have recently been working on a top secret project that includes the wonderful native libraries of the libgdx project in order to have a decent Box2d physics simulation. I am using Android Studio 0.4.0 as of this week, and the recently released 0.7.3 of the Gradle Android build tools includes a new way to bundle shared libraries with an APK. Here’s how to do it.
build.gradle file and add something like the following in the android section:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
The magic is on line 14, where you can see the new
jniLibs.srcDir property being set. The trailing slash isn’t required. I just did it to be explicit that it is a directory.
Then make a
jni directory in the project directory, and inside there you can place the shared libraries you want to bundle into your APK under specific abi directories. For example:
jni jni/armeabi jni/armeabi/libgdx.so jni/armeabi-v7a jni/armeabi-v7a/libgdx.so jni/x86 jni/x86/libgdx.so
So far, this only works in application modules, not library modules.