react-native-opencv-tutorial icon indicating copy to clipboard operation
react-native-opencv-tutorial copied to clipboard

Could not invoke RNOpenCvLibrary.checkForBlurryImage

Open AntaresRahman opened this issue 6 years ago • 18 comments

I am getting the following error when I take a picture:


Could not invoke RNOpenCvLibrary.checkForBlurryImage

null

No implementation found for long org.opencv.core.Mat.n_Mat() (tried Java_org_opencv_core_Mat_n_1Mat and Java_org_opencv_core_Mat_n_1Mat__)

I found a similar issue on stackoverflow, but couldn't figure out how to solve this: https://stackoverflow.com/questions/35090838/no-implementation-found-for-long-org-opencv-core-mat-n-mat-error-using-opencv

Any clues? Thanks!

AntaresRahman avatar Jun 10 '18 23:06 AntaresRahman

Hi, I still need help with this if anyone has any ideas. Thanks!

AntaresRahman avatar Jun 24 '18 06:06 AntaresRahman

@AntaresRahman I cloned the repository and followed the steps in the README.MD file and couldn't reproduce your error. Can you add more details? Like what phone did you use?

Meph1k avatar Jun 25 '18 17:06 Meph1k

I have same issue actually ....

pohsiu avatar Jul 10 '18 01:07 pohsiu

I've tried it before with jdk 8, but now I'm using jdk 10. I suspect this might be the issue if it works with jdk 7. However if this is the issue, I would really still hope to get it to work with the latest java as jdk 7 is getting pretty old now:

$ java --version
java 10.0.1 2018-04-17
Java(TM) SE Runtime Environment 18.3 (build 10.0.1+10)
Java HotSpot(TM) 64-Bit Server VM 18.3 (build 10.0.1+10, mixed mode)

I'm using One Plus 3 for testing.

For my gradle build, I'm using the following (same for gradle builds in OpenCV, react-native-camera and react-native-svg and I believe all other node_modules):

compileSdkVersion 28
    buildToolsVersion "28.0.0"

    defaultConfig {
        applicationId "com.reactnativeopencvtutorial"
        minSdkVersion 16
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        ndk {
            abiFilters "armeabi-v7a", "x86"
        }
    }

My gradle-wrapper.properties is using distribution 4.8.1: distributionUrl=https\://services.gradle.org/distributions/gradle-4.8.1-all.zip

With Android Plugin for Gradle: classpath 'com.android.tools.build:gradle:3.1.0

I tried with the package.json that comes with this tutorial, but then I changed it to see if it works with everything set to latest:

{
  "name": "reactNativeOpencvTutorial",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest"
  },
  "dependencies": {
    "lodash": "latest",
    "react": "latest",
    "react-native": "latest",
    "react-native-camera": "latest",
    "react-native-easy-toast": "latest",
    "react-native-svg": "latest",
    "ws": "latest"
  },
  "devDependencies": {
    "babel-jest": "latest",
    "babel-preset-react-native": "latest",
    "jest": "latest",
    "react-test-renderer": "latest"
  },
  "jest": {
    "preset": "react-native"
  }
}

Having no luck with that one error. This was the only related issue I found online: https://stackoverflow.com/questions/35090838/no-implementation-found-for-long-org-opencv-core-mat-n-mat-error-using-opencv

But the code for the opencv library seems a little different in the way that it's structured/implemented compared to the solution above. So I'm not quite understanding where to fit this solution. Mainly because I see that the Mat variable is declared in the checkForBlurryImage method which is defined inside android/app/src/main/java/com/reactlibrary/RNOpenCvLibraryModule.java. And then the Async Initialization of OpenCV using OpenCVManager is being handled in the android/app/src/main/java/com/reactnativeopencvtutorial/MainApplication.java file. Maybe the issue is that RNOpenCvLibraryPackage() is being called before loading OpenCV inside MainApplication.java, because of the way Java 8 or 10 is compiling compared to Java 7?

AntaresRahman avatar Jul 10 '18 03:07 AntaresRahman

@AntaresRahman If it doesn't work with a certain version of JDK, then you should rather head to the React Native team at Facebook :)

Meph1k avatar Jul 10 '18 07:07 Meph1k

I tried to change build.gradle file on android studio, below android studio it would show up syn gradle now link, after that, it works,

other steps same as before, just this diff,

pohsiu avatar Jul 10 '18 09:07 pohsiu

@Meph1k which jdk are you using? I'm not really sure if it's an issue with the jdk version.

@pohsiu which jdk are you using? Also, could you elaborate a little on that please? I might be having that same issue, but not quite sure what you mean. I will try to look at it soon and see if I understand what you mean, but some clarification would be great! :)

Thanks for the help!

AntaresRahman avatar Jul 11 '18 06:07 AntaresRahman

@AntaresRahman I used 1.8 did you try modify your gradle file on android studio? that would appear a option "sync gradle now" after clicked it and sync, the error disappear

But you need restart, that means you need to back to square one

pohsiu avatar Jul 11 '18 06:07 pohsiu

I did the gradle syncing and used jdk 1.8. Still have the same problem.

ltung avatar Jul 27 '18 00:07 ltung

I figured out my problem. It is because I put the library in wrong folder. i.e. the native library should be in "jinLibs" instead of, incorrectly, "jinLibs\libs".

ltung avatar Jul 30 '18 19:07 ltung

Thanks @ltung your solution worked for me.

abrararies avatar Aug 05 '18 13:08 abrararies

@AntaresRahman

does it work for you now?

piotr-s-brainhub avatar Oct 05 '18 00:10 piotr-s-brainhub

@piotr-s-brainhub I still can't figure why this is not working. http://answers.opencv.org/question/171681/android-canny-problem-no-implementation-found/ Here they say it could because of the OpenCV version, but I am not sure how to change in the code.

mirzakhalov avatar Nov 12 '18 00:11 mirzakhalov

@mirzakhalov is this working?

SwagatRanjit84 avatar Feb 24 '19 00:02 SwagatRanjit84

@SwagatRanjit84 The next steps works for me. The problem is where you locate the main library. You can try these steps: if you are using Android studio then: 1- Copy your OpenCV-android-sdk/sdk/native/libs/(armeabi|armeabi-v7a|x86|...) to /app/src/main/jniLibs/(armeabi|armeabi-v7a|x86|...).

2- rebuild.

Good Luck.

davidrd108 avatar Mar 04 '19 14:03 davidrd108

@AntaresRahman @pohsiu @ltung @mirzakhalov

does the @davidrd108 solution from the previous comment work for you?

piotr-s-brainhub avatar Feb 24 '20 11:02 piotr-s-brainhub

I'm also getting the same error. err [TypeError: null is not an object (evaluating '_OpenCV.default.checkForBlurryImage')] I tried above all solution but negative plz update solutions.

devkrkanhaiya avatar May 18 '20 11:05 devkrkanhaiya

@devkrkanhaiya

I answered your issue (https://github.com/brainhubeu/react-native-opencv-tutorial/issues/22).

piotr-s-brainhub avatar May 18 '20 15:05 piotr-s-brainhub