Originally Posted on:http://www.kylethielk.com/blog/include-native-so-library-in-apk-with-android-studio/
Using the Android NDK is well documented throughout the Internet if your is still using Eclipse. The process is basically, the same with Android Studio until, the time comes to build your APK. The APK would build fine, but your library *.so file would be a missing from the APK and if you attempt to load it with Syst Em.loadlibrary ("MyLibrary") you'll get:
1 |
java.lang.UnsatisfiedLinkError: Couldn‘t load mylibrary from loader dalvik.system.PathClassLoader
|
You can view the contents of your apk with the following command to verify libmylibrary.so are not in the APK:
Android Studio ' s build tool would not look in the usual place:
12 |
SharedLibrary : libmylibrary.soInstall : libmylibrary.so => libs/armeabi/libmylibrary.so
|
The trick (thanks to this thread:https://groups.google.com/forum/#!msg/adt-dev/nqobkd2gl_8/z5ywavch4h4j) are to move Libmylibrary.so to:
1 |
src/main/jniLibs/armeabi/libmylibrary.so
|
Voila, your native code is now compiled into your APK. This should work with build tools 0.8+
Include Native *.so Library in APK with Android Studio