Hello, I’m trying to run opencv on qt with android, initially I took static libraries from the kit, but there were problems with them in the absence of AmediaExtractor and so on. so I compiled dynamic libraries from sources, disabling fat_java, they were successfully assembled in qt, but when the application starts, it crashes with an exception:
ava.lang.UnsatisfiedLinkError: dlopen failed: library “libopencv_core.so” not found: needed by /data/app/~~R8s5DfUqJCgALlqrx8DPig==/com.Demo.DemoApp-MYIKl0rddoPtWYMlO2my9g==/lib/arm/libandroidApp_armeabi-v7a.so in namespace classloader-namespace
as I understand it, the problem is that I did not add libraries to the android folder and did not link them in gradle, but I do not really understand how to do this, I will be grateful for the help, because all the guides show that you need to connect libraries from android studio, but I work in qt and do not have this opportunity.
Includies in PRO file
OPENCV_ANDROID = $${PWD}/OpenCVFiles/opencv_build/
INCLUDEPATH += $$OPENCV_ANDROID/
android {
LIBS += \
-L$$OPENCV_ANDROID/lib/armeabi-v7a/ \
-L$$OPENCV_ANDROID/3rdparty/lib/armeabi-v7a/ \
-L$$OPENCV_ANDROID/jni/armeabi-v7a/ \
-ltegra_hal \
-lcpufeatures \
-llibjpeg-turbo \
-llibtiff \
-llibwebp \
-llibopenjp2\
-llibpng \
-lIlmImf \
-llibprotobuf \
-lquirc \
-littnotify \
-lade \
-lopencv_core \
-lopencv_flann \
-lopencv_imgproc \
-lopencv_ml \
-lopencv_photo \
-lopencv_dnn \
-lopencv_features2d \
-lopencv_imgcodecs \
-lopencv_videoio\
-lopencv_calib3d \
-lopencv_highgui \
-lopencv_objdetect \
-lopencv_stitching \
-lopencv_video \
-lopencv_gapi \
-lopencv_java4
ANDROID_PACKAGE_SOURCE_DIR=$${PWD}/android
}
gradle file
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.0'
}
}
repositories {
google()
jcenter()
}
apply plugin: ‘com.android.application’
dependencies {
implementation fileTree(dir: ‘libs’, include: [’.jar’, '.aar’])
implementation ‘com.google.android.gms:play-services-ads:19.+’
implementation ‘com.google.android.gms:play-services-auth:18.+’
implementation ‘com.google.http-client:google-http-client-gson:1.26.0’
implementation(‘com.google.api-client:google-api-client-android:1.26.0’) {
exclude group: ‘org.apache.httpcomponents’
}
implementation (‘com.google.apis:google-api-services-drive:v3-rev173-1.25.0’) {
exclude group: ‘org.apache.httpcomponents’
}
implementation ‘com.google.android.ump:user-messaging-platform:1.0.0’
implementation ‘androidx.annotation:annotation:1.1.0’
implementation ‘com.google.guava:guava:28.2-android’
}
android {
/*******************************************************
* The following variables:
* - androidBuildToolsVersion,
* - androidCompileSdkVersion
* - qt5AndroidDir - holds the path to qt android files
* needed to build any Qt application
* on Android.
*
* are defined in gradle.properties file. This file is
* updated by QtCreator and androiddeployqt tools.
* Changing them manually might break the compilation!
*******************************************************/
compileSdkVersion 28
//buildToolsVersion “x.y.z” // not needed since com.android.tools.build:gradle:3.0.0
defaultConfig {
minSdkVersion 26
targetSdkVersion 28
externalNativeBuild {
cmake {
arguments "-DANDROID_STL=c++_shared"
targets "opencv_jni_shared"
}
}
}
buildToolsVersion '28.0.3'
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = [qt5AndroidDir + '/src', 'src', 'java']
aidl.srcDirs = [qt5AndroidDir + '/src', 'src', 'aidl']
res.srcDirs = [qt5AndroidDir + '/res', 'res']
resources.srcDirs = ['resources']
renderscript.srcDirs = ['src']
assets.srcDirs = ['assets']
jniLibs.srcDirs = ['libs']
}
}
lintOptions {
abortOnError false
}
// Do not compress Qt binary resources file
aaptOptions {
noCompress 'rcc'
}
defaultConfig {
resConfig "en"
minSdkVersion = qtMinSdkVersion
targetSdkVersion = qtTargetSdkVersion
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/notice.txt'
exclude 'META-INF/ASL2.0'
}
}