Tag Archives: /system/lib]]] couldn’t find

How to package native library (*.so) in Android Studio

Recently I was working on some projects where the native library (*.so) is used. It builds in Android Studio without any problem, but when I run it on the Android devices, it crashes with the following error message:

Can’t load xxx library: java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file “/data/app/“],nativeLibraryDirectories=[/vendor/lib, /system/lib]]] couldn’t find “

After millions of trial and error, here comes the solution:

    1. Create a folder called “lib” (must be exactly this name)
    2. Create subfolders in lib with desired architecture name such as “armeabi-v7a”, “armeabi” etc.
    3. Put all your *.so file in the just created folder
    4. Now your folder structure should be like this:

    5. Zip the lib folder into a file, e.g.;
    6. Rename this –> abc.jar
    7. Copy this abc.jar to your project subfolder, anywhere should do, but I would typically put it in the app\libs\abc,jar
    8. In the build.gradle, add:

dependencies {
compile files(‘libs/abc.jar’)

Rebuild, that is all! Happy Coding!




Posted by on December 3, 2015 in Android, Programming


Tags: , , , , , , , , ,