java.lang.UnsatisfiedLinkError: dlopen失败:未找到库".../.../lib/libopencv_core.so"

0ve6wy6x  于 2022-12-23  发布在  Java
关注(0)|答案(2)|浏览(304)

我正在使用android和openCV开发一个人脸识别应用程序。我的android studio版本是3.5.3,openCV版本是3.4.10。我运行应用程序的手机是arm64-v8a,我收到这个错误:

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.
    • 生成分级**
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')
}

为了删除此错误,我对我的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"
    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')
}

现在我得到这个错误:

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.

8ehkhllq

8ehkhllq1#

根据堆栈跟踪:java.lang.UnsatisfiedLinkError: dlopen失败:"/data/app/com.示例. opencvdemo-o8BNe1NoZik-avIk3otJaw = =/lib/arm64/libjniopencv_contrib.so "是32位而不是64位
所以我假设你的库没有arm64-v8a的资源,要解决这个问题,你必须在你的项目中添加arm64-v8a arch的opencv.so文件

bgibtngc

bgibtngc2#

如果在jniLibs文件夹中找不到.so文件,请执行以下步骤
1-在defaultConfig下的buildgradle文件中添加Android中的源路径

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

2-在buildgradle文件的defaultConfig中添加ndk。abifilters可以在包含丢失文件的jniLibs文件夹中找到。

ndk{
     abiFilters 'armeabi-v7a'
   }

如果未解决,请访问此链接https://blog.csdn.net/u010920692/article/details/114476490

相关问题