当我在Android Studio中集成Open cv进行眼睛检测时。在集成消息打印之后,Opencv安装成功消息生成但在给出错误之后。
无法从加载程序加载detection_based_tracker dalvik.system.PathClassLoader [DexPathList [[拉链 文件 “/data/app/com.example.admin.lanskart-2.apk”],nativeLibraryDirectories = [/数据/ APP-LIB / com.example.admin.lanskart-2,/销售商/ lib下,/系统/ lib中]]]:findLibrary 返回null
Process: com.example.admin.lanskart, PID: 24341
java.lang.UnsatisfiedLinkError: Couldn't load detection_based_tracker from loader dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.example.admin.lanskart-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.admin.lanskart-2, /vendor/lib, /system/lib]]]: findLibrary returned null
at java.lang.Runtime.loadLibrary(Runtime.java:365)
at java.lang.System.loadLibrary(System.java:553)
at com.example.admin.lanskart.MainActivity$1.onManagerConnected(MainActivity.java:69)
at org.opencv.android.AsyncServiceHelper$3.onServiceConnected(AsyncServiceHelper.java:319)
at android.app.LoadedApk$ServiceDispatcher.doConnected(LoadedApk.java:1140)
at android.app.LoadedApk$ServiceDispatcher$RunConnection.run(LoadedApk.java:1157)
at android.os.Handler.handleCallback(Handler.java:808)
at android.os.Handler.dispatchMessage(Handler.java:103)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:5299)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:825)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:641)
at dalvik.system.NativeStart.main(Native Method)
答案 0 :(得分:0)
您需要在gradle中定义jni源的目录。你的app gradle应该是这样的:
apply plugin: 'com.android.model.application'
model {
android {
compileSdkVersion = 22
buildToolsVersion = "23.0.0"
defaultConfig.with {
applicationId = "enter.your.packagename"
minSdkVersion.apiLevel = 10
targetSdkVersion.apiLevel = 22
versionCode = 1
versionName = "1.0"
}
}
android.buildTypes {
release {
minifyEnabled = false
proguardFiles += file('proguard-rules.pro')
}
}
/*
* native build settings
*/
android.ndk {
moduleName = "ndklibrarysample"
cppFlags += ["-std=c++11", "-fexceptions", "-frtti"]
cppFlags += "-I${file("D:yourpathtothesefiles/OpenCV-3.0.0-android-sdk-1/OpenCV-android-sdk/sdk/native/jni/include")}".toString()
ldLibs += ["android", "EGL", "GLESv2", "dl", "log", "z"]
stl = "gnustl_static"
}
android.productFlavors {
create("arm") {
ndk.with {
abiFilters += "armeabi"
File curDir = file('./')
curDir = file(curDir.absolutePath)
String libsDir = curDir.absolutePath + "\\src\\main\\jniLibs\\armeabi\\"
ldLibs += libsDir + "libopencv_java3.so"
}
}
create("armv7") {
ndk.with {
abiFilters += "armeabi-v7a"
File curDir = file('./')
curDir = file(curDir.absolutePath)
String libsDir = curDir.absolutePath + "\\src\\main\\jniLibs\\armeabi-v7a\\"
ldLibs += libsDir + "libopencv_java3.so"
}
}
create("x86") {
ndk.with {
abiFilters += "x86"
File curDir = file('./')
curDir = file(curDir.absolutePath)
String libsDir = curDir.absolutePath + "\\src\\main\\jniLibs\\x86\\"
ldLibs += libsDir + "libopencv_java3.so"
}
}
create("mips") {
ndk.with {
abiFilters += "mips"
File curDir = file('./')
curDir = file(curDir.absolutePath)
String libsDir = curDir.absolutePath + "\\src\\main\\jniLibs\\mips\\"
ldLibs += libsDir + "libopencv_java3.so"
}
}
create("fat") {
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:22.2.1'
compile project(':libraries:opencv')
}
并将您的类路径从您的项目gradle文件更改为此版本,并确保ndk路径为local.properties文件
classpath 'com.android.tools.build:gradle-experimental:0.2.0'