Android Studio:OpenCv:Face-detection = java.lang.UnsatisfiedLinkError:无法从loader dalvik.system.PathClassLoader加载detection_based_tracker

时间:2017-07-25 09:59:51

标签: java android c++ opencv

java.lang.UnsatisfiedLinkError: Couldn't load detection_based_tracker from 
loader dalvik.system.PathClassLoader[DexPathList[[zip file 
"/data/app/org.opencv.samples.facedetect-9.apk"],nativeLibraryDirectories=
[/data/app-lib/org.opencv.samples.facedetect-9, /vendor/lib, /system/lib]]]: 
findLibrary returned null

我也有这个错误。

at.org.opencv.samples.facedetect.FdActivity $ 1.onManagerConnected(FdActivity.java:67)

相关行:

66:                // Load native library after(!) OpenCV initialization
67:                System.loadLibrary("detection_based_tracker");

Gradle版本: 2.14.1

插件版本: 2.2.0 我的build.gradle(app):

apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"

defaultConfig {
    applicationId "org.opencv.samples.facedetect"
    minSdkVersion 8
    targetSdkVersion 8

    ndk {
        moduleName "detection_based_tracker"
    }
}
sourceSets.main {
    jniLibs.srcDir 'src/main/libs'
    jni.srcDirs = []
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
    }
}
dependencies {
compile project(':openCVLibrary300')
}

我添加了这些行,但我在主目录下没有libs目录:

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

screenshot of left bar

此外没有* .so文件。

Android.mk

LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
#OPENCV_INSTALL_MODULES:=off
#OPENCV_LIB_TYPE:=SHARED
ifdef OPENCV_ANDROID_SDK
ifneq ("","$(wildcard $(OPENCV_ANDROID_SDK)/OpenCV.mk)")
include ${OPENCV_ANDROID_SDK}/OpenCV.mk
else
include ${OPENCV_ANDROID_SDK}/sdk/native/jni/OpenCV.mk
endif
else
include ../../sdk/native/jni/OpenCV.mk
endif
LOCAL_SRC_FILES  := DetectionBasedTracker_jni.cpp
LOCAL_C_INCLUDES += $(LOCAL_PATH)
LOCAL_LDLIBS     += -llog -ldl
LOCAL_MODULE     := detection_based_tracker
include $(BUILD_SHARED_LIBRARY)

Aplication.mk

APP_STL := gnustl_static
APP_CPPFLAGS := -frtti -fexceptions
APP_ABI := armeabi-v7a
APP_PLATFORM := android-8

如何使用opencv运行这个面部检测项目?我应该在build.gradle中添加什么?

0 个答案:

没有答案