适用于Android的OpenCV示例中的UnsatisfiedLinkError

时间:2017-06-06 09:50:46

标签: android java-native-interface

我已经阅读了很多关于这个问题的非常相似的帖子,但我找不到问题。

我正试图从tutorial-2-mixedprocessing运行OpenCV-android-sdk/samples(版本3.2.0)。在尽可能好the official tutorial之后,我将其导入Android Studio(2.3)并调整Makefile中Tegra的路径以适合我的系统(Ubuntu 16.04)。目标平台是项目探戈平板电脑(Android 4.4.2)。

当我在构建文件夹中检查APK时,库libmixed_sample.so不会显示。当然,加载库失败了UnsatisfiedLinkError

没有本机代码的简单示例可以正常工作。

为什么它不复制图书馆的任何想法?

的build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 15
    buildToolsVersion "25.0.3"

    defaultConfig {
        applicationId "org.opencv.samples.tutorial2"
        minSdkVersion 9
        targetSdkVersion 9

        ndk {
            moduleName "mixed_sample"
        }
    }

    sourceSets {
        main {
            jni.srcDirs = ["libs"]
        }
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
    splits {
        abi {
            enable true
            reset()
            include 'armeabi-v7a'
            universalApk false
        }
    }
}

dependencies {
    compile project(':openCVLibrary2482')
}

Android.mk

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

OPENCVROOT:=/home/fs/NVPACK/OpenCV-2.4.8.2-Tegra-sdk
include ${OPENCVROOT}/sdk/native/jni/OpenCV-tegra3.mk

LOCAL_MODULE    := mixed_sample
LOCAL_SRC_FILES := jni_part.cpp
LOCAL_LDLIBS +=  -llog -ldl

include $(BUILD_SHARED_LIBRARY)

错误:

06-06 10:30:41.077 24476-24476/org.opencv.samples.tutorial2 E/AndroidRuntime: FATAL EXCEPTION: main                                                                              Process: org.opencv.samples.tutorial2, PID: 24476
  java.lang.UnsatisfiedLinkError: Couldn't load mixed_sample from loader dalvik.system.PathClassLoader[
        DexPathList[
            [zip file "/data/app/org.opencv.samples.tutorial2-2.apk"],
            nativeLibraryDirectories=[
                /data/app-lib/org.opencv.samples.tutorial2-2, 
                /system/lib, 
                /vendor/lib, 
                /system/lib
                ]
            ]]: findLibrary returned null
    at java.lang.Runtime.loadLibrary(Runtime.java:358)
    at java.lang.System.loadLibrary(System.java:526)
    at org.opencv.samples.tutorial2.Tutorial2Activity$1.onManagerConnected(Tutorial2Activity.java:49)
    at org.opencv.android.AsyncServiceHelper$3.onServiceConnected(AsyncServiceHelper.java:318)
    at [...] 

您可以在github上找到修改过的示例。

0 个答案:

没有答案