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 :
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.<clinit>(opencv_contrib.java:97)
at com.googlecode.javacv.cpp.opencv_contrib.createLBPHFaceRecognizer(Native Method)
at com.example.opencvdemo.CtrRecognizer.<init>(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.<clinit>(opencv_contrib.java:97)
at com.googlecode.javacv.cpp.opencv_contrib.createLBPHFaceRecognizer(Native Method)
at com.example.opencvdemo.CtrRecognizer.<init>(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.
build.gradle
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')
}
For removing this error I made changes to my build.gradle as follows:
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')
}
Now I'm getting this error :
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.<clinit>(opencv_contrib.java:97)
at com.googlecode.javacv.cpp.opencv_contrib.createLBPHFaceRecognizer(Native Method)
at com.example.opencvdemo.CtrRecognizer.<init>(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.<clinit>(opencv_contrib.java:97)
at com.googlecode.javacv.cpp.opencv_contrib.createLBPHFaceRecognizer(Native Method)
at com.example.opencvdemo.CtrRecognizer.<init>(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.
According to the stack trace: java.lang.UnsatisfiedLinkError: dlopen failed: "/data/app/com.example.opencvdemo-o8BNe1NoZik-avIk3otJaw==/lib/arm64/libjniopencv_contrib.so" is 32-bit instead of 64-bit
So I suppose that your library doesn't have resources for arm64-v8a, to solve this problem you must add to your project opencv .so files for arm64-v8a arch
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With