在qt pro文件中的libopencv_java3.so

时间:2016-07-01 07:08:58

标签: android c++ qt opencv android-ndk

我正在Qt和OpenCV中制作Android应用程序。

它正在使用桌面Linux,但在Android上失败了:

D/dalvikvm( 8059): Trying to load lib /data/app-lib/com.myselfxyz.testapp-1/libTestApp.so 0x421b4f98
E/dalvikvm( 8059): dlopen("/data/app-lib/com.myselfxyz.testapp-1/libTestApp.so") failed: Cannot load library: soinfo_link_image(linker.cpp:1673): could not load library "libopencv_java3.so" needed by "libTestApp"; caused by load_library(linker.cpp:771): library "libopencv_java3.so" not found

在我的设备上部署应用程序后,文件 libopencv_java3.so 位于 / data / app-lib / com中的 libTestApp.so 旁边。 myxyz.testapp-1 目录,所以我不知道,为什么不能找到它。

我正在使用:

  • Android NDK r10e
  • OpenCV-android-sdk 3.1.0
  • Qt kit:armeabi-v7a(GCC 4.9,Qt 5.5.1)
  • 我的手机有Android版本4.2.2,但我认为不重要。

我的qt pro文件如下:

TEMPLATE = app
TARGET = TestApp

CONFIG += mobility c++11
MOBILITY += sensors

QT += qml quick widgets declarative sensors core multimedia

SOURCES += main.cpp \
    bridge.cpp \
    imageprocessor.cpp

INCLUDEPATH += /usr/lib/jvm/java-7-openjdk-i386/include \
    /usr/lib/jvm/java-7-openjdk-i386/include/linux \

linux:!android {
    INCLUDEPATH += /opt/OpenCV/include/
    LIBS += -L/opt/OpenCV/build/lib \
        -lopencv_core -lopencv_highgui -lopencv_imgproc -lopencv_videoio
}

android {
    QT += androidextras
    ANDROID_OPENCV = /opt/OpenCV-android-sdk/sdk/native
    INCLUDEPATH += $$ANDROID_OPENCV/jni/include
    ANDROID_PACKAGE_SOURCE_DIR = $$PWD/android
    LIBS += -L$$ANDROID_OPENCV/libs/armeabi-v7a \
        -L$$PWD/android/libs/armeabi-v7a \
        -L$$OUT_PWD \
        -lopencv_core -lopencv_features2d -lopencv_flann -lopencv_highgui -lopencv_imgcodecs -lopencv_imgproc -lopencv_ml -lopencv_objdetect \
        -lopencv_photo -lopencv_shape -lopencv_stitching -lopencv_superres -lopencv_ts -lopencv_video -lopencv_videoio -lopencv_videostab \
        -lopencv_java3
}

RESOURCES += qml.qrc

# Additional import path used to resolve QML modules in Qt Creator's code model
QML_IMPORT_PATH =

# Default rules for deployment.
include(deployment.pri)

HEADERS += \
    bridge.h \
    imageprocessor.h

DISTFILES += \
    android/AndroidManifest.xml \
    android/res/values/libs.xml \
    android/src/com/myselfxyz/testapp/JniExport.java \
    android/src/com/myselfxyz/testapp/TestApp.java

ANDROID_PACKAGE_SOURCE_DIR = $$PWD/android

1 个答案:

答案 0 :(得分:0)

这个答案假设您已经设法在没有opencv的情况下运行您的应用程序,所以其余的都是相应的。

转到项目设置,找到“构建步骤”。

应该有一个名为构建Android APK 的步骤。点击详细信息。在其他库列表中,添加libopencv_java3.so。它通常位于\sdk\native\libs\armeabi-v7a文件夹中。