react-native-document-scanner: error: cannot find symbol import org.opencv.DocumentScannerPackage

Screen Shot 2019-06-17 at 3 55 04 PM

This is my package.json file

{
  "name": "TestApp",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest"
  },
  "dependencies": {
    "react": "16.6.3",
    "react-native": "0.57.8",
    "react-native-document-scanner": "git+https://github.com/Michaelvilleneuve/react-native-document-scanner.git#android"
  },
  "devDependencies": {
    "babel-jest": "24.8.0",
    "jest": "24.8.0",
    "metro-react-native-babel-preset": "0.54.1",
    "react-test-renderer": "16.6.3"
  },
  "jest": {
    "preset": "react-native"
  }
}

Was struggling for past 2 days… unable to get any solutions… I just installed using android branch and trying it in android mobile.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 3
  • Comments: 18 (2 by maintainers)

Most upvoted comments

The automatic linking seems to have failed retrieving the package name. The import line should look like this :

import com.documentscanner.DocumentScannerPackage

It is work to add react-native.config.js with below image content in this project root dir! I have tested it

image

Looks like this is an issue with React Native’s 60+ auto-linking. It looks like this, along with andreluisjunqueira/react-native-documentscanner-android need to be linked manually, following the instructions described in Junqueira’s readme.

To prevent auto-linking, create a file (if it doesn’t already exist) called “react-native-config.js” and add the following:

module.exports = {
  dependencies: {
    'react-native-document-scanner': {
      platforms: {
        android: null, // disable Android platform, other platforms will still autolink if provided
      },
    },
  },
};

The best thing to do, would be to actually look at the files involved in auto-linking and see if we can’t update them to get things to work with React-Native 60+

Hi everyone, has anyone managed to make react-native-document-scanner work with react native 0.60.x on both platforms? I succeeded on iOS but on Android even after having disabled auto linking, the only thing obtained is a black screen. If someone did it, or met the same issues and passed, could he let me know how?

Hi @Sride, did you get react-native-document-scanner to work with zahidahmed024’s suggestion?

Thank you in advance

Same problem goes for me…

Hey @ceyhuncfc9 Linking opencv is the problem, refer this Michaelvilleneuve/react-native-perspective-image-cropper#26 in this we have linked opencv.

@Michaelvilleneuve Yes it is…

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.scan" xmlns:tools="http://schemas.android.com/tools">

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.CAMERA" />

    <application 
      tools:replace="android:allowBackup" 
      android:name=".MainApplication" 
      android:label="@string/app_name" 
      android:icon="@mipmap/ic_launcher" 
      android:allowBackup="false" 
      android:theme="@style/AppTheme">

      <activity
        android:name=".MainActivity"
        android:label="@string/app_name"
        android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
        android:windowSoftInputMode="adjustResize">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
      </activity>
      <activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
    </application>

</manifest>

@Michaelvilleneuve thanks for the response, you saved my day, after changing this line, the app shows blank white page. the app.js has only DocumentScanner

Here is the changed line.

import com.facebook.react.ReactApplication;
import com.documentscanner.DocumentScannerPackage;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import com.facebook.soloader.SoLoader;