Skip to content
Advertisement

Android, opencv – No implementation found for long org.opencv.core.Mat.n_Mat() when trying to initialize Mat

I want to do some things using OpenCV and I’m trying to create Mat object:

JavaScript

On this line I get the error:

JavaScript

I have OpenCV as separate module in my android project and have imported it into my main module by adding implementation project(path: ':OpenCV') in its build.gradle in dependencies section.

I have seen one simillar question but it is answered with using OpenCvManager which I wouldn’t like to use in my project. If I’m getting right, my users will be forced to install this manager separately before using my app, right? It is disgousting.

UPD 1

I’ve added

JavaScript

in my MainActivity.java. It prints “SUCCEEDED” but the error hasn’t gone. However, it changed:

JavaScript

UPD 2

Oops error in UPD 1 was because of argument in new Mat(). With no args there is no errors yet. Investigation continues.

Advertisement

Answer

Seems like I have found the solution (worked for OpenCV 3). It was needed to copy folder sdknativelibs from downloaded SDK into the project’s root and name it jniLibs. Each of its forders has single file named libopencv_java3.so, as follows:

jniLibs in project structure

Also, probably, it is useful to add this code to your main activity:

JavaScript

Bad side: these files add 80 Mb to your APK after build. Better solutions are welcome.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement