KXJiao / 2016-Summer-Projects

2016 Summer
0 stars 0 forks source link

java.lang.UnsatisfiedLinkError: couldn't find "libjniopencv_core.so" and "libopencv_imgproc.so" #7

Closed azhang24 closed 8 years ago

azhang24 commented 8 years ago

I am working on live video processing using opencv and javacv. Unfortunately, I have continued to run into the run time error titled above.

The following is my project structure: image

In the jniLibs folder, I included the opencv.jar, javacv.jar, javacpp.jar, and ffmpeg.jar.

Build.gradle (Module: app): apply plugin: 'com.android.model.application'

model {
android {
    compileSdkVersion 24
    buildToolsVersion "24.0.0"

    defaultConfig.with {
        applicationId "cn.truthvision.stopsignproject"
        minSdkVersion.apiLevel 15
        targetSdkVersion.apiLevel 21
        versionCode 1
        versionName "1.0"

        multiDexEnabled true
    }

}
android.ndk {
    moduleName "StopSignDetection"
    ldLibs.addAll(['log'])
    cppFlags.add("-std=c++11")
    cppFlags.add("-fexceptions")
    cppFlags.add("-I${file("C:/NVPACK/OpenCV-2.4.8.2-Tegra-sdk/sdk/native/jni/include")}".toString())
    cppFlags.add("-I${file("C:/NVPACK/OpenCV-2.4.8.2-Tegra-sdk/sdk/native/jni/include/opencv")}".toString())
    cppFlags.add("-I${file("C:/NVPACK/OpenCV-2.4.8.2-Tegra-sdk/sdk/native/jni/include/opencv2")}".toString())

    ldLibs.addAll(["android", "EGL", "GLESv2", "dl", "log", "z"])
    stl "gnustl_shared"//"gnustl_static"//"gnustl_shared"//"stlport_static"
}
android.buildTypes {
    release {
        minifyEnabled false
        proguardFiles.add(file('proguard-android.txt'))
        //getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
android.productFlavors {
    create("arm") {
        ndk.with {
            abiFilters.add("armeabi")
            File curDir = file('./')
            curDir = file(curDir.absolutePath)
            String libsDir = curDir.absolutePath + "\\src\\main\\jniLibs\\armeabi\\"
            //"-L" +
            ldLibs.add(libsDir + "libopencv_core.a")
            ldLibs.add(libsDir + "libopencv_imgproc.a")
            ldLibs.add(libsDir + "libopencv_java.so")
            ldLibs.add(libsDir + "libopencv_features2d.a")
            ldLibs.add(libsDir + "libopencv_highgui.a")
            ldLibs.add(libsDir + "libopencv_info.so")
        }
    }
    create("arm7") {
        ndk.with {
            abiFilters.add("armeabi-v7a")
            File curDir = file('./')
            curDir = file(curDir.absolutePath)
            String libsDir = curDir.absolutePath + "\\src\\main\\jniLibs\\armeabi-v7a\\"
            //"-L"  +
            ldLibs.add(libsDir + "libopencv_core.a")
            ldLibs.add(libsDir + "libopencv_imgproc.a")
            ldLibs.add(libsDir + "libopencv_java.so")
            ldLibs.add(libsDir + "libopencv_features2d.a")
            ldLibs.add(libsDir + "libopencv_highgui.a")
            ldLibs.add(libsDir + "libopencv_info.so")

        }
    }
    create("x86") {
        ndk.with {
            abiFilters.add("x86")
        }
    }
    create("mips") {
        ndk.with {
            abiFilters.add("mips")
        }
    }
    create("fat") {
    }
}
android.packagingOptions {
    exclude 'META-INF/services/javax.annotation.processing.Processor'
    pickFirst 'META-INF/maven/org.bytedeco.javacpp-presets/opencv/pom.properties'
    pickFirst 'META-INF/maven/org.bytedeco.javacpp-presets/opencv/pom.xml'
    pickFirst 'META-INF/maven/org.bytedeco.javacpp-presets/ffmpeg/pom.properties'
    pickFirst 'META-INF/maven/org.bytedeco.javacpp-presets/ffmpeg/pom.xml'
}

}

dependencies {
 compile fileTree(dir: 'libs', include: ['*.jar'])
  testCompile 'junit:junit:4.12'
compile project(':stopsignlib')
//    compile 'com.google.android.gms:play-services:9.2.1'

//    compile 'com.google.android.gms:play-services-ads:9.2.1'

//    compile 'com.google.android.gms:play-services-auth:9.2.1'

//    compile 'com.google.android.gms:play-services-gcm:9.2.1'
compile project(':openCVLibrary2482')
compile 'com.android.support:appcompat-v7:24.0.0'
compile 'com.android.support:design:24.0.0'
compile 'com.google.android.gms:play-services-maps:9.2.0'
compile 'com.google.android.gms:play-services-location:9.2.0'
compile 'com.firebase:firebase-client-android:2.3.1'
compile 'org.bytedeco:javacv:1.1'
compile 'org.bytedeco.javacpp-presets:opencv:2.4.8'
compile 'org.bytedeco.javacpp-presets:ffmpeg:2.8.1-1.1'
//compile 'com.android.support:multidex:1.0.0'

/*compile 'org.bytedeco:javacv'
    compile group: 'org.bytedeco.javacpp-presets', name: 'opencv', version: '2.4.8.2', classifier: 'android-arm'
    compile group: 'org.bytedeco.javacpp-presets', name: 'ffmpeg', version: '2.5.1–0.10', classifier: 'android-arm'*/
//compile files('src/main/jniLibs/ffmpeg-android-arm.jar')
//compile files('src/main/jniLibs/ffmpeg-android-x86.jar')
//compile files('src/main/jniLibs/ffmpeg.jar')
//compile files('src/main/jniLibs/javacpp.jar')
//compile files('src/main/jniLibs/javacv.jar')
//compile files('src/main/jniLibs/opencv-android-arm.jar')
//compile files('src/main/jniLibs/opencv-android-x86.jar')
//compile files('src/main/jniLibs/opencv.jar')
}

Build.gradle (Project: StopSignProject):

buildscript {
        repositories {
        //jcenter()
           mavenCentral()
        }
dependencies {
    classpath 'com.android.tools.build:gradle-experimental:0.7.2'

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
    }
}

allprojects {
   repositories {
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

Android.mk:

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

#OPENCV_CAMERA_MODULES:=off
#OPENCV_INSTALL_MODULES:=off
#OPENCV_LIB_TYPE:=SHARED
include ../../sdk/native/jni/OpenCV.mk

LOCAL_SRC_FILES  := StopSignDetection.cpp
LOCAL_C_INCLUDES += $(LOCAL_PATH)
LOCAL_LDLIBS     += -llog -ldl

LOCAL_MODULE     := StopSignDetection

include $(BUILD_SHARED_LIBRARY)

My error log:

08-24 15:39:48.895 7905-7905/cn.truthvision.stopsignproject E/AndroidRuntime: FATAL EXCEPTION: main Process: cn.truthvision.stopsignproject, PID: 7905 java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/cn.truthvision.stopsignproject-2/base.apk"],nativeLibraryDirectories=[/data/app/cn.truthvision.stopsignproject-2/lib/arm, /vendor/lib, /system/lib]]] couldn't find "libjniopencv_core.so" at java.lang.Runtime.loadLibrary(Runtime.java:366) at java.lang.System.loadLibrary(System.java:988) at org.bytedeco.javacpp.Loader.loadLibrary(Loader.java:597) at org.bytedeco.javacpp.Loader.load(Loader.java:438) at org.bytedeco.javacpp.Loader.load(Loader.java:381) at org.bytedeco.javacpp.opencv_core.(opencv_core.java:10) at java.lang.Class.classForName(Native Method) at java.lang.Class.forName(Class.java:309) at org.bytedeco.javacpp.Loader.load(Loader.java:413) at org.bytedeco.javacpp.Loader.load(Loader.java:381) at org.bytedeco.javacpp.helper.opencv_core$AbstractArray.(opencv_core.java:109) at cn.truthvision.stopsignproject.AutoRecording.initRecorder(AutoRecording.java:531) at cn.truthvision.stopsignproject.AutoRecording.onCreate(AutoRecording.java:208) at android.app.Activity.performCreate(Activity.java:6557) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1120) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3096) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3252) at android.app.ActivityThread.access$1000(ActivityThread.java:197) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1671) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:145) at android.app.ActivityThread.main(ActivityThread.java:6892) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199) Caused by: java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/cn.truthvision.stopsignproject-2/base.apk"],nativeLibraryDirectories=[/data/app/cn.truthvision.stopsignproject-2/lib/arm, /vendor/lib, /system/lib]]] couldn't find "libopencv_imgproc.so" at java.lang.Runtime.loadLibrary(Runtime.java:366) at java.lang.System.loadLibrary(System.java:988) at org.bytedeco.javacpp.Loader.loadLibrary(Loader.java:597) at org.bytedeco.javacpp.Loader.load(Loader.java:429) at org.bytedeco.javacpp.Loader.load(Loader.java:381)  at org.bytedeco.javacpp.opencv_core.(opencv_core.java:10)  at java.lang.Class.classForName(Native Method)  at java.lang.Class.forName(Class.java:309)  at org.bytedeco.javacpp.Loader.load(Loader.java:413)  at org.bytedeco.javacpp.Loader.load(Loader.java:381)  at org.bytedeco.javacpp.helper.opencv_core$AbstractArray.(opencv_core.java:109)  at cn.truthvision.stopsignproject.AutoRecording.initRecorder(AutoRecording.java:531)  at cn.truthvision.stopsignproject.AutoRecording.onCreate(AutoRecording.java:208)  at android.app.Activity.performCreate(Activity.java:6557)  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1120)  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3096)  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3252)  at android.app.ActivityThread.access$1000(ActivityThread.java:197)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1671)  at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:145)  at android.app.ActivityThread.main(ActivityThread.java:6892)  at java.lang.reflect.Method.invoke(Native Method)  at java.lang.reflect.Method.invoke(Method.java:372)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199) 

Any help is appreciated! Thanks!

KXJiao commented 8 years ago

Can you push your changes to the Andrew's-UI changes branch so that I can see the code?

azhang24 commented 8 years ago

issue no longer persists with the methods in autorecording im using now