I have been trying to get OpenCV and the android version of tesseract (tess-two) to work with my android app. I am developing in Android Studio 1.4, the problem is that if I add the tess-two dependency alone, the app works fine and I can load the tess-two library fine. Next when I add the OpenCV dependency to the app, it breaks the support for the tess-two library and throws me this runtime error:
Caused by: java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.app.ocrapp-1/base.apk"],nativeLibraryDirectories=[/data/app/com.app.ocrapp-1/lib/arm64, /vendor/lib64, /system/lib64]]] couldn't find "libpngt.so"
at java.lang.Runtime.loadLibrary(Runtime.java:366)
at java.lang.System.loadLibrary(System.java:989)
at com.googlecode.tesseract.android.TessBaseAPI.<clinit>(TessBaseAPI.java:43)
at com.app.ocrapp.util.Libraries.<clinit>(Libraries.java:12)
Once I remove the OpenCV libraries and dependency from the app, tess-two begins to work again.
Here is my OpenCV build.gradle:
apply plugin: 'android-library'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
minSdkVersion 15
targetSdkVersion 21
versionCode 3000
versionName "3.0.0"
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
res.srcDirs = ['res']
aidl.srcDirs = ['src']
jniLibs.srcDirs = ['oclibs']
}
}
}
And here is my tess-two build.gradle:
apply plugin: 'android-library'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
minSdkVersion 15
targetSdkVersion 21
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
res.srcDirs = ['res']
jniLibs.srcDirs = ['libs']
}
}
}
Also here is a picture of my project structure, each library is circled with their respective libs folders circled as well (containing the .so files): Project Structure
All help would be greatly appreciated. I have been trying to fix this for days now.
-----EDIT------
I have solved this issue and have posted a solution below.