Question

I'm using OpenCV in my android instrumentation tests. It works fine on newer devices (gnex, nexus 5, nexus 7) but not on older ones (nexus one, samsung GT-P7500R). I'm using static initialization for this library (as opposed to using the manager app that pools/shares the native libs).

It's the same build code, based on gradle and including the same .so files, for both armeabi and armeabi-v7a.

I've installed OpenCVManager and another app using it and it works fine even on older devices. I peeked inside the apk and even copied the same .so files over but still getting the same error message:

java.lang.UnsatisfiedLinkError: Couldn't load opencv_java: findLibrary returned null
at java.lang.Runtime.loadLibrary(Runtime.java:429)
at java.lang.System.loadLibrary(System.java:554)
at org.opencv.android.StaticHelper.loadLibrary(StaticHelper.java:54)
at org.opencv.android.StaticHelper.initOpenCVLibs(StaticHelper.java:85)
at org.opencv.android.StaticHelper.initOpenCV(StaticHelper.java:29)
at org.opencv.android.OpenCVLoader.initDebug(OpenCVLoader.java:51)

Any ideas on what else could be different? I looked inside the instrumentation apk (debug test) and the lib files are there...

Edit: I tried various setups but none of them work: - just armeabi files in armeabi folder - just armeabi-v7a files in armeabi-v7a folder - just armeabi files in top folder (lib folder inside apk) - just armeabi-v7a files in top folder (lib folder inside apk) - manually loading opencv_java - manually loading OpenCVENgine, OpenCVEngine_jni ("borrowed" from the OpenCVManager app).

I've tried some of these approaches on other devices and they work fine...

Was it helpful?

Solution

It turns out this was an issue with the fact that the opencv library was part of the dependencies for the instrumentation test project.

Switching from androidTestCompile to compile in the build.gradle file (basically, adding the dependency to the app under test rather than the test app) makes the library load work properly. I'll dig some more to see if there are any workarounds.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top