0

I'm new to android studio and am working on an existing project that is using OpenCV. I need to implement CMU's Pocketsphinx for Android, and in following the installation steps they give I have created a jniLibs folder in my /src directory of my project, and placed the appropriate files for pocketsphinx in there.

This is where the problem occurs- when I do this, I suddenly get the following error message:

java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.robodoot.dr.facetracktest-2/base.apk"],nativeLibraryDirectories=[/data/app/com.robodoot.dr.facetracktest-2/lib/arm, /data/app/com.robodoot.dr.facetracktest-2/base.apk!/lib/armeabi-v7a, /vendor/lib, /system/lib]]] couldn't find "libjniopencv_core.so"

I do NOT get this error if I don't have the jniLibs folder in the /src directory, though then of course I get an error from pocketSphinx saying that it can't find it's required .so files.

What's more, after looking through OpenCV's SDK, I noticed there is no such file "libjniopencv_core.so". It doesn't exist anywhere, there are other .so files but none of which with that name. Even if I install all of the armeabi and what not directories from openCV to my new jniLibs folder, I still get this error message.

How can I tell android studio to only load the pocketsphinx jniLibs files, and disregard searching that directory for openCV .so files?

Ajv2324
  • 422
  • 8
  • 24

2 Answers2

1

you can do this by adding following code in gradle

android {
    ...
    defaultConfig {
        ...
        ndk {
            abiFilters "armeabi-v7a", "x86","armeabi"
        }

        packagingOptions {
            exclude "lib/arm64-v8a/mysofile.so"
        }
    }
}

replace arm64-v8a/mysofile.so with whatever you want to exclude.

Vikash Kumar Verma
  • 1,068
  • 2
  • 14
  • 30
  • Do you know how I can find the directory that it's looking in based off the error message I supplied above? I tried all of the options in the nativeLibraryDirectories path but none of them seemed to work. – Ajv2324 Oct 15 '16 at 18:59
  • @Ajv2324 Can you show me your folder structure and some more logs – Vikash Kumar Verma Oct 16 '16 at 18:39
0

How can I tell android studio to only load the pocketsphinx jniLibs files, and disregard searching that directory for openCV .so files?

You should not disregard an important file. libjniopencv_core.so is required by opencv.

What's more, after looking through OpenCV's SDK, I noticed there is no such file "libjniopencv_core.so".

It must be inside opencv-android-arm.jar together with other important so files.

It's not clear why file conflicts, it should be some issue with gradle. You need to check internals of APK what so files are actually packed inside. Most likely you try to pack different architectures like armeabi and armeabi-v7. You might need to pack .so files from the same architecture.

Nikolay Shmyrev
  • 24,897
  • 5
  • 43
  • 87