Can't add .so file to Android Studio 3.5.3 using jniLibs-ThrowExceptions

Exception or error:

I’m trying to add a .so file to a new Android project. I’m using Android Studio 3.5.3. I’ve done what was recommended here and here ; so I created folders (jniLibs/arm64-v8a, etc) in src/main and added this to app/build.gradle:

sourceSets {
    main {
        jniLibs.srcDirs = ['src/main/jniLibs']

I placed the file in /app/src/main/jniLibs/arm64-v8a (yes, 64-bit should be ok). The project will compile just fine, but on execution it will show the following error in logcat:

02-17 10:25:31.719 3691-3691/com.example.bmdtest03 E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.bmdtest03, PID: 3691
    java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.example.bmdtest03-2/base.apk"],nativeLibraryDirectories=[/data/app/com.example.bmdtest03-2/lib/x86_64, /vendor/lib64, /system/lib64]]] couldn't find ""
        at java.lang.Runtime.loadLibrary(
        at java.lang.System.loadLibrary(
        at com.example.bmdtest03.MainActivity.<clinit>(
        at java.lang.reflect.Constructor.newInstance(Native Method)
        at java.lang.Class.newInstance(
        at android.os.Handler.dispatchMessage(
        at android.os.Looper.loop(
        at java.lang.reflect.Method.invoke(Native Method)
        at java.lang.reflect.Method.invoke(

Conclusion: the file is there, the source is updated in build.gradle, what am I missing?

How to solve:

You can manually generate the .so file with NDK . Then you can add the file in your jni folder.

Add the NDK path to your

Refer this page :

If its not works. You can create javah then you can access it.
Link to make javah :

Leave a Reply

Your email address will not be published. Required fields are marked *