我在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。因此位于libTestApp旁边。在/data/app-lib/com.myselfxyz中添加。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配置文件看起来像:
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
这个答案假设您已经设法在没有opencv的情况下运行应用程序,因此所有其余的都相应地设置。
进入你的项目设置,找到"Build steps"
应该有一个叫做Build Android APK的步骤。点击Details。在Additional libraries列表中,添加libopencv_java3.so
。通常在sdknativelibsarmeabi-v7a
文件夹