title: java.lang.UnsatisfiedLinkError: dlopen failed: library "../../lib/libopencv_core.so" not found
body: <p>I'm developing a face recognition application using android and openCV. My android studio version is 3.5.3 and openCV version is 3.4.10. The phone on which I'm running my application is arm64-v8a and I'm getting this error :</p>
  
  <pre><code>2020-04-15 15:00:40.425 15788-15788/com.example.opencvdemo E/AndroidRuntime: FATAL EXCEPTION: main
  Process: com.example.opencvdemo, PID: 15788
  java.lang.UnsatisfiedLinkError: dlopen failed: "/data/app/com.example.opencvdemo-o8BNe1NoZik-avIk3otJaw==/lib/arm64/libjniopencv_contrib.so" is 32-bit instead of 64-bit
      at java.lang.Runtime.loadLibrary0(Runtime.java:1071)
      at java.lang.Runtime.loadLibrary0(Runtime.java:1007)
      at java.lang.System.loadLibrary(System.java:1667)
      at com.googlecode.javacpp.Loader.loadLibrary(Loader.java:711)
      at com.googlecode.javacpp.Loader.load(Loader.java:586)
      at com.googlecode.javacpp.Loader.load(Loader.java:540)
      at com.googlecode.javacv.cpp.opencv_contrib.&lt;clinit&gt;(opencv_contrib.java:97)
      at com.googlecode.javacv.cpp.opencv_contrib.createLBPHFaceRecognizer(Native Method)
      at com.example.opencvdemo.CtrRecognizer.&lt;init&gt;(CtrRecognizer.java:40)
      at com.example.opencvdemo.MainActivity$1.onManagerConnected(MainActivity.java:94)
      at org.opencv.android.AsyncServiceHelper$3.onServiceConnected(AsyncServiceHelper.java:319)
      at android.app.LoadedApk$ServiceDispatcher.doConnected(LoadedApk.java:1956)
      at android.app.LoadedApk$ServiceDispatcher$RunConnection.run(LoadedApk.java:1988)
      at android.os.Handler.handleCallback(Handler.java:883)
      at android.os.Handler.dispatchMessage(Handler.java:100)
      at android.os.Looper.loop(Looper.java:224)
      at android.app.ActivityThread.main(ActivityThread.java:7520)
      at java.lang.reflect.Method.invoke(Native Method)
      at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)
   Caused by: java.lang.UnsatisfiedLinkError: dlopen failed: "/data/app/com.example.opencvdemo-o8BNe1NoZik-avIk3otJaw==/lib/arm64/libopencv_contrib.so" is 32-bit instead of 64-bit
      at java.lang.Runtime.loadLibrary0(Runtime.java:1071)
      at java.lang.Runtime.loadLibrary0(Runtime.java:1007)
      at java.lang.System.loadLibrary(System.java:1667)
      at com.googlecode.javacpp.Loader.loadLibrary(Loader.java:711)
      at com.googlecode.javacpp.Loader.load(Loader.java:577)
      at com.googlecode.javacpp.Loader.load(Loader.java:540) 
      at com.googlecode.javacv.cpp.opencv_contrib.&lt;clinit&gt;(opencv_contrib.java:97) 
      at com.googlecode.javacv.cpp.opencv_contrib.createLBPHFaceRecognizer(Native Method) 
      at com.example.opencvdemo.CtrRecognizer.&lt;init&gt;(CtrRecognizer.java:40) 
      at com.example.opencvdemo.MainActivity$1.onManagerConnected(MainActivity.java:94) 
      at org.opencv.android.AsyncServiceHelper$3.onServiceConnected(AsyncServiceHelper.java:319) 
      at android.app.LoadedApk$ServiceDispatcher.doConnected(LoadedApk.java:1956) 
      at android.app.LoadedApk$ServiceDispatcher$RunConnection.run(LoadedApk.java:1988) 
      at android.os.Handler.handleCallback(Handler.java:883) 
      at android.os.Handler.dispatchMessage(Handler.java:100) 
      at android.os.Looper.loop(Looper.java:224) 
      at android.app.ActivityThread.main(ActivityThread.java:7520) 
      at java.lang.reflect.Method.invoke(Native Method) 
      at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539) 
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950) 
  2020-04-15 15:00:40.427 15788-15788/com.example.opencvdemo E/MQSEventManagerDelegate: failed to get MQSService.
  </code></pre>
  
  <p><strong>build.gradle</strong></p>
  
  <pre><code>apply plugin: 'com.android.application'
  
  android {
  compileSdkVersion 28
  //buildToolsVersion "29.0.0"
  defaultConfig {
      applicationId "com.example.opencvdemo"
      minSdkVersion 19
      targetSdkVersion 28
      versionCode 1
      versionName "1.0"
      testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
  
  }
  buildTypes {
      release {
          minifyEnabled false
          proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
      }
  
  }
  
  sourceSets {
      main {
          jni.srcDirs = ['src/main/jniLibs']
          jniLibs.srcDir 'src/main/libs'
      }
    }
  }
  dependencies {
  implementation fileTree(dir: 'libs', include: ['*.jar','*.so'])
  implementation 'androidx.legacy:legacy-support-v4:1.0.0'
  implementation 'com.intuit.sdp:sdp-android:1.0.6'
  implementation 'com.intuit.ssp:ssp-android:1.0.6'
  implementation 'com.google.android.material:material:1.1.0'
  implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
  testImplementation 'junit:junit:4.12'
  androidTestImplementation 'androidx.test.ext:junit:1.1.1'
  androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
  implementation 'com.github.bumptech.glide:glide:3.7.0'
  implementation 'com.github.markushi:circlebutton:1.1'
  implementation project(path: ':openCV3410')
  }
  </code></pre>
  
  <p>For removing this error I made changes to my <strong>build.gradle</strong> as follows:</p>
  
  <pre><code>apply plugin: 'com.android.application'
  
  android {
  compileSdkVersion 28
  //buildToolsVersion "29.0.0"
  defaultConfig {
      applicationId "com.example.opencvdemo"
      minSdkVersion 19
      targetSdkVersion 28
      versionCode 1
      versionName "1.0"
      testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
      ndk {
          abiFilters "armeabi-v7a", "x86", "armeabi", "mips"
      }
      externalNativeBuild {
          cmake {
              cppFlags "-frtti -fexceptions"
          }
      }
  }
  buildTypes {
      release {
          minifyEnabled false
          proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
      }
  
  }
  
  sourceSets {
      main {
          jni.srcDirs = ['src/main/jniLibs']
          jniLibs.srcDir 'src/main/libs'
       }
     }
  }
  dependencies {
  implementation fileTree(dir: 'libs', include: ['*.jar','*.so'])
  implementation 'androidx.legacy:legacy-support-v4:1.0.0'
  implementation 'com.intuit.sdp:sdp-android:1.0.6'
  implementation 'com.intuit.ssp:ssp-android:1.0.6'
  implementation 'com.google.android.material:material:1.1.0'
  implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
  testImplementation 'junit:junit:4.12'
  androidTestImplementation 'androidx.test.ext:junit:1.1.1'
  androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
  implementation 'com.github.bumptech.glide:glide:3.7.0'
  implementation 'com.github.markushi:circlebutton:1.1'
  implementation project(path: ':openCV3410')
  }
  </code></pre>
  
  <p>Now I'm getting this error :</p>
  
  <pre><code>2020-04-15 15:11:19.353 17892-17892/com.example.opencvdemo E/AndroidRuntime: FATAL EXCEPTION: main
  Process: com.example.opencvdemo, PID: 17892
  java.lang.UnsatisfiedLinkError: dlopen failed: library "../../lib/libopencv_core.so" not found
      at java.lang.Runtime.loadLibrary0(Runtime.java:1071)
      at java.lang.Runtime.loadLibrary0(Runtime.java:1007)
      at java.lang.System.loadLibrary(System.java:1667)
      at com.googlecode.javacpp.Loader.loadLibrary(Loader.java:711)
      at com.googlecode.javacpp.Loader.load(Loader.java:586)
      at com.googlecode.javacpp.Loader.load(Loader.java:540)
      at com.googlecode.javacv.cpp.opencv_contrib.&lt;clinit&gt;(opencv_contrib.java:97)
      at com.googlecode.javacv.cpp.opencv_contrib.createLBPHFaceRecognizer(Native Method)
      at com.example.opencvdemo.CtrRecognizer.&lt;init&gt;(CtrRecognizer.java:40)
      at com.example.opencvdemo.MainActivity$1.onManagerConnected(MainActivity.java:94)
      at com.example.opencvdemo.MainActivity.onResume(MainActivity.java:233)
      at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1454)
      at android.app.Activity.performResume(Activity.java:8050)
      at android.app.ActivityThread.performResumeActivity(ActivityThread.java:4236)
      at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:4278)
      at android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:52)
      at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:176)
      at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2040)
      at android.os.Handler.dispatchMessage(Handler.java:107)
      at android.os.Looper.loop(Looper.java:224)
      at android.app.ActivityThread.main(ActivityThread.java:7520)
      at java.lang.reflect.Method.invoke(Native Method)
      at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)
   Caused by: java.lang.UnsatisfiedLinkError: dlopen failed: library "../../lib/libopencv_core.so" not found
      at java.lang.Runtime.loadLibrary0(Runtime.java:1071)
      at java.lang.Runtime.loadLibrary0(Runtime.java:1007)
      at java.lang.System.loadLibrary(System.java:1667)
      at com.googlecode.javacpp.Loader.loadLibrary(Loader.java:711)
      at com.googlecode.javacpp.Loader.load(Loader.java:577)
      at com.googlecode.javacpp.Loader.load(Loader.java:540) 
      at com.googlecode.javacv.cpp.opencv_contrib.&lt;clinit&gt;(opencv_contrib.java:97) 
      at com.googlecode.javacv.cpp.opencv_contrib.createLBPHFaceRecognizer(Native Method) 
      at com.example.opencvdemo.CtrRecognizer.&lt;init&gt;(CtrRecognizer.java:40) 
      at com.example.opencvdemo.MainActivity$1.onManagerConnected(MainActivity.java:94) 
      at com.example.opencvdemo.MainActivity.onResume(MainActivity.java:233) 
      at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1454) 
      at android.app.Activity.performResume(Activity.java:8050) 
      at android.app.ActivityThread.performResumeActivity(ActivityThread.java:4236) 
      at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:4278) 
      at android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:52) 
      at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:176) 
      at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97) 
      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2040) 
      at android.os.Handler.dispatchMessage(Handler.java:107) 
      at android.os.Looper.loop(Looper.java:224) 
      at android.app.ActivityThread.main(ActivityThread.java:7520) 
      at java.lang.reflect.Method.invoke(Native Method) 
      at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539) 
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950) 
     2020-04-15 15:11:19.361 17892-17892/com.example.opencvdemo E/MQSEventManagerDelegate: failed to get MQSService.
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/h59Lw.png" rel="noreferrer"><img src="https://i.stack.imgur.com/h59Lw.png" alt="jniLibs folders"></a></p>
  
  <p><a href="https://i.stack.imgur.com/bPjMU.png" rel="noreferrer"><img src="https://i.stack.imgur.com/bPjMU.png" alt="jniLibs files"></a></p>