title: How to fix 'couldn't find "libjnisgfplib.so' error in Android
body: <p>I'm developing an Android application that use Secure-Gen Fingerprint SDK. For this I have use <em>jniLibs</em> also app has encryption decryption feature so I have used <em>CMake</em> to save some password in <em>native-lib.cpp</em> file. </p>
  
  <p>When I don't use CMake everything works fine, but using both together throws an exception on Screen where fingerprint SDK is used.</p>
  
  <p>Below is stack trace of exception:</p>
  
  <pre><code>java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/app.mypackagename.debug-2/base.apk", zip file "/data/app/app.mypackagename.debug-2/split_lib_slice_0_apk.apk"],nativeLibraryDirectories=[/data/app/app.mypackagename.debug-2/lib/arm, /data/app/app.mypackagename.debug-2/base.apk!/lib/armeabi-v7a, /data/app/app.mypackagename.debug-2/split_lib_slice_0_apk.apk!/lib/armeabi-v7a, /system/lib, /vendor/lib, /system/vendor/lib, /product/lib]]] couldn't find "libjnisgfplib.so"
          at java.lang.Runtime.loadLibrary0(Runtime.java:989)
          at java.lang.System.loadLibrary(System.java:1533)
          at SecuGen.FDxSDKPro.JSGFPLib.&lt;clinit&gt;(JSGFPLib.java:196)
          at app.mypackagename.modules.home.fragments.VerifyBiometricFragment.onCreateView(VerifyBiometricFragment.java:114)
          at android.support.v4.app.Fragment.performCreateView(Fragment.java:2439)
          at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1460)
          at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1784)
          at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1852)
          at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:802)
          at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2625)
          at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2411)
          at android.support.v4.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2366)
          at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2273)
          at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:733)
          at android.os.Handler.handleCallback(Handler.java:761)
          at android.os.Handler.dispatchMessage(Handler.java:98)
          at android.os.Looper.loop(Looper.java:156)
          at android.app.ActivityThread.main(ActivityThread.java:6617)
          at java.lang.reflect.Method.invoke(Native Method)
  </code></pre>
  
  <p>Below is build.gradle file part</p>
  
  <pre><code>apply plugin: 'com.android.application'
  
  android {
      compileSdkVersion 28
  
      defaultConfig {
          applicationId "app.mypackagename"
          minSdkVersion 16
          targetSdkVersion 28
          versionCode 1
          versionName "1.0"
          testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
          flavorDimensions 'default'
          multiDexEnabled true
  
          externalNativeBuild {
              cmake {
                  cppFlags ""
              }
          }
      }
      buildTypes {
          release {
              multiDexKeepFile file('multidex-config.txt')
              shrinkResources true
              minifyEnabled true
              proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
          }
          debug {
              shrinkResources true
              minifyEnabled true
              proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
              debuggable true
              applicationIdSuffix ".debug"
          }
      }
      externalNativeBuild {
          cmake {
              path "CMakeLists.txt"
          }
      }
      productFlavors {
          MyProductFlavor {
  
          }
      }
      sourceSets {
          main {
              java {
                  srcDirs('src/MyProductFlavor/java/src', 'src/main/java/src')
              }
              res {
                  srcDirs('src/MyProductFlavor/res/src', 'src/main/res/src')
              }
          }
          MyProductFlavor {
              java {
                  srcDirs('src/MyProductFlavor/java/src', 'src/main/java/src')
              }
              res {
                  srcDirs('src/MyProductFlavor/res/src', 'src/main/res/src')
              }
          }
  
  
      }
      lintOptions {
          checkReleaseBuilds false
          abortOnError false
      }
  }
  
  dependencies {
      /* Android Default*/
      implementation fileTree(include: ['*.jar'], dir: 'libs')
      implementation 'com.android.support:appcompat-v7:28.0.0'
      implementation 'com.android.support.constraint:constraint-layout:1.1.3'
      implementation 'com.android.support:multidex:1.0.3'
      implementation 'com.android.support:support-v4:28.0.0'
      testImplementation 'junit:junit:4.12'
      androidTestImplementation 'com.android.support.test:runner:1.0.2'
      androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
      implementation 'com.android.support:design:28.0.0'
      implementation 'com.android.support:cardview-v7:28.0.0'
      implementation 'com.android.support:recyclerview-v7:28.0.0'
  
      implementation files('libs/FDxSDKProAndroid.jar')
  }
  </code></pre>
  
  <p>Below is screenshot attached for my application architecture:</p>
  
  <p><a href="https://i.stack.imgur.com/KZmDm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KZmDm.png" alt="enter image description here"></a></p>
  
  <p>I have tried using the following methods</p>
  
  <ul>
  <li>Tried adding NDK block with <code>abiFilter</code> in <code>build.gradle</code>.</li>
  <li>Tried adding
  the following block in <code>build.gragle</code> file</li>
  </ul>
  
  <pre><code>    android {
          splits {
              abi {
                  enable true
                  reset()
                  include 'armeabi-v7a'
              }
          }
      }
  </code></pre>
  
  <ul>
  <li>Tried adding <code>android.useDeprecatedNdk=true</code> in <code>gradle.properties</code></li>
  </ul>
  
  <p>None of above method worked for me the the exception is still there. </p>
  
  <p>I have checked through <strong>Analyze APK</strong> and it shows these .so files are packaged. </p>
  
  <p><a href="https://i.stack.imgur.com/ibWFi.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ibWFi.png" alt="enter image description here"></a></p>
  
  <p><a href="https://i.stack.imgur.com/xthQF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xthQF.png" alt="enter image description here"></a></p>