react-native-document-scanner icon indicating copy to clipboard operation
react-native-document-scanner copied to clipboard

react-native-document-scanner not build for android

Open umutcetinkaya opened this issue 5 years ago โ€ข 32 comments

Does anyone have an idea ?

run : react-native run-android

result :

BUILD FAILED in 6s

error Failed to install the app. Make sure you have the Android development environment set up: https://facebook.github.io/react-native/docs/getting-started.html#android-development-environment. Run CLI with --verbose flag for more details. Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081 /Users/workpc/Projects//android/app/src/main/java/com/isegeldim/MainApplication.java:10: error: cannot find symbol import org.opencv.DocumentScannerPackage; ^ symbol: class DocumentScannerPackage location: package org.opencv /Users/workpc/Projects//android/app/src/main/java/com/isegeldim/MainApplication.java:16: error: package com.reactlibrary does not exist import com.reactlibrary.RNPdfScannerPackage; ^ /Users/workpc/Projects//android/app/build/generated/rncli/src/main/java/com/facebook/react/PackageList.java:27: error: cannot find symbol import org.opencv.DocumentScannerPackage; ^ symbol: class DocumentScannerPackage location: package org.opencv /Users/workpc/Projects//android/app/build/generated/rncli/src/main/java/com/facebook/react/PackageList.java:86: error: cannot find symbol new DocumentScannerPackage(), ^ symbol: class DocumentScannerPackage location: class PackageList 4 errors

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':app:compileDebugJavaWithJavac'.

Compilation failed; see the compiler error output for details.

  • Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 6s

at checkExecSyncError (child_process.js:591:13)
at execFileSync (child_process.js:611:13)
at runOnAllDevices (/Users/workpc/Projects/***/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:74:39)
at buildAndRun (/Users/workpc/Projects/***/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/index.js:158:41)
at then.result (/Users/workpc/Projects/***/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/index.js:125:12)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)

umutcetinkaya avatar Sep 25 '19 12:09 umutcetinkaya

Duplicated https://github.com/Michaelvilleneuve/react-native-document-scanner/issues/52

Basically, change import org.opencv.DocumentScannerPackage; to import com.documentscanner.DocumentScannerPackage in MainApplication.java

jorgemasta avatar Sep 25 '19 14:09 jorgemasta

@jorgemarrero I'm having the same problem. I made the change as you said, but the problem was not solved?

umutcetinkaya avatar Sep 25 '19 15:09 umutcetinkaya

Have you follow https://github.com/Michaelvilleneuve/react-native-document-scanner#android-only ?

jorgemasta avatar Sep 25 '19 15:09 jorgemasta

@jorgemarrero Yes, I did it all step by step. But it didn't. :(

umutcetinkaya avatar Sep 25 '19 16:09 umutcetinkaya

Task :app:compileDebugJavaWithJavac FAILED

Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0. Use '--warning-mode all' to show the individual deprecation warnings. See https://docs.gradle.org/5.4.1/userguide/command_line_interface.html#sec:command_line_warnings 185 actionable tasks: 31 executed, 154 up-to-date /Users/workpc/Projects/projectname/android/app/build/generated/rncli/src/main/java/com/facebook/react/PackageList.java:27: error: cannot find symbol import org.opencv.DocumentScannerPackage; ^ symbol: class DocumentScannerPackage location: package org.opencv /Users/workpc/Projects/projectname/android/app/build/generated/rncli/src/main/java/com/facebook/react/PackageList.java:86: error: cannot find symbol new DocumentScannerPackage(), ^ symbol: class DocumentScannerPackage location: class PackageList 2 errors

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':app:compileDebugJavaWithJavac'.

Compilation failed; see the compiler error output for details.

  • Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 8s

error Failed to install the app. Make sure you have the Android development environment set up: https://facebook.github.io/react-native/docs/getting-started.html#android-development-environment. Run CLI with --verbose flag for more details. Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081 /Users/workpc/Projects/projectname/android/app/build/generated/rncli/src/main/java/com/facebook/react/PackageList.java:27: error: cannot find symbol import org.opencv.DocumentScannerPackage; ^ symbol: class DocumentScannerPackage location: package org.opencv /Users/workpc/Projects/projectname/android/app/build/generated/rncli/src/main/java/com/facebook/react/PackageList.java:86: error: cannot find symbol new DocumentScannerPackage(), ^ symbol: class DocumentScannerPackage location: class PackageList 2 errors

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':app:compileDebugJavaWithJavac'.

Compilation failed; see the compiler error output for details.

  • Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 8s

at checkExecSyncError (child_process.js:591:13)
at execFileSync (child_process.js:611:13)
at runOnAllDevices (/Users/workpc/Projects/projectname/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:74:39)
at buildAndRun (/Users/workpc/Projects/projectname/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/index.js:158:41)
at then.result (/Users/workpc/Projects/projectname/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/index.js:125:12)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)

umutcetinkaya avatar Sep 25 '19 16:09 umutcetinkaya

This could be related to this issue #56 ๐Ÿค”

I am actually using my own fork of this package https://github.com/Woonivers/react-native-document-scanner

You can try it: yarn add @woonivers/react-native-document-scanner but you will need to change all from react-native-document-scanner to @woonivers/react-native-document-scanner in your project.

This package has done a great job, but I feel it is not maintained.

jorgemasta avatar Sep 25 '19 16:09 jorgemasta

@jorgemarrero your react-native version ?

umutcetinkaya avatar Sep 25 '19 17:09 umutcetinkaya

@jorgemarrero your react-native version ?

0.59.9

jorgemasta avatar Sep 25 '19 17:09 jorgemasta

I am using version 0.60. Would you mind if I went to the repo you called? @jorgemarrero

umutcetinkaya avatar Sep 25 '19 17:09 umutcetinkaya

Ahรก, probably that's the problem. 0.60 changes a lot in Android, I haven't update for that reason :(

jorgemasta avatar Sep 25 '19 17:09 jorgemasta

@jorgemarrero What can you do to make it run at 0.60.xx ? do you have an idea ?

umutcetinkaya avatar Sep 25 '19 17:09 umutcetinkaya

@jorgemarrero What can you do to make it run at 0.60.xx ? do you have an idea ?

No idea, I'm sorry ๐Ÿ˜Ÿ I will face that problem in the next few weeks/months.

The android part is very inspired by this repository https://github.com/ctodobom/OpenNoteScanner, maybe you can find some solution based on that.

jorgemasta avatar Sep 26 '19 08:09 jorgemasta

Hi @umutcetinkaya , I have updated my fork to work with react-native 0.60+

jorgemasta avatar Oct 02 '19 11:10 jorgemasta

hello @jorgemarrero. Trying to get it to compile, but getting

PackageList.java:17: error: cannot find symbol import org.opencv.DocumentScannerPackage;

I'm using 0.61.1. Any idea?

haneul512 avatar Oct 02 '19 12:10 haneul512

hello @jorgemarrero. Trying to get it to compile, but getting

PackageList.java:17: error: cannot find symbol import org.opencv.DocumentScannerPackage;

I'm using 0.61.1. Any idea?

What's version are you using?

jorgemasta avatar Oct 02 '19 12:10 jorgemasta

@jorgemarrero I have cloned your master (2.0.0 I suppose) and trying to run it from example folder

haneul512 avatar Oct 02 '19 12:10 haneul512

@jorgemarrero I have cloned your master (2.0.0 I suppose) and trying to run it from example folder

Sorry, the example folder was pointing to the previous version. I am working on make that dynamically, but I am having issues with auto-linking. I have updated master with that change.

jorgemasta avatar Oct 02 '19 12:10 jorgemasta

@jorgemarrero Did you know that you are running over 0.60 where you are currently forking?

umutcetinkaya avatar Oct 05 '19 03:10 umutcetinkaya

hello @jorgemarrero. Trying to get it to compile, but getting

PackageList.java:17: error: cannot find symbol import org.opencv.DocumentScannerPackage;

I'm using 0.61.1. Any idea?

You should disable auto link in RN 0.60+ Edit / Create react-native.config.js

module.exports = {
  dependencies: {
    'react-native-document-scanner': {
      platforms: {
        android: null
      }
    }
  }
};

ntvinhit avatar Nov 26 '19 03:11 ntvinhit

This could be related to this issue #56 ๐Ÿค”

I am actually using my own fork of this package https://github.com/Woonivers/react-native-document-scanner

You can try it: yarn add @woonivers/react-native-document-scanner but you will need to change all from react-native-document-scanner to @woonivers/react-native-document-scanner in your project.

This package has done a great job, but I feel it is not maintained.

Chamo, a ti te ha funcionado este repo con RN 0.60 ?

Gricardov avatar Mar 28 '20 19:03 Gricardov

@Gricardov Is @woonivers/react-native-document-scanner working for both Android and iOS?

Yangeok avatar Apr 02 '20 01:04 Yangeok

same issue for me as well. Anyone found the fix???

hegdeMadan avatar Jul 09 '20 08:07 hegdeMadan

This repo @woonivers/react-native-document-scanner is great. Work on react-native > 0.6.0.

However, important things like detectedRectangle doesn't work on Android, only on IOS. In my case it is very important to me.

alessandrots avatar Jul 21 '20 16:07 alessandrots

After 2 long days of work, I finally succeeded to make it work. Here is what I've done, inspired by the previous comments and this issue on react-native-splash-screen

Install

$ yarn add https://github.com/Michaelvilleneuve/react-native-document-scanner

Link manually for android First, we will disable autolink on android , so Edit / Create react-native.config.js at the root of your project

module.exports = {
  dependencies: {
    'react-native-document-scanner': {
      platforms: {
        android: null
      }
    }
  }
};

Now link manually react-native-document-scanner and openCV in your settings.gradle file

include ':react-native-document-scanner'
project(':react-native-document-scanner').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-document-scanner/android')

include ':openCVLibrary310'
project(':openCVLibrary310').projectDir = new File(rootProject.projectDir,'../node_modules/react-native-document-scanner/android/openCVLibrary310')

In android/app/src/main/java/com/your/project/MainActivity.java add

import com.documentscanner.DocumentScannerPackage;

In android/app/src/main/java/com/your/project/MainApplication.java add

import com.documentscanner.DocumentScannerPackage;

In android/app/build.gradle add

dependencies {
    [...]
    compile project(':react-native-document-scanner')
}

The process already described in the readme for iOS works correctly for me.

obertil avatar Sep 07 '20 15:09 obertil

After 2 long days of work, I finally succeeded to make it work. Here is what I've done, inspired by the previous comments and this issue on react-native-splash-screen

Install

$ yarn add https://github.com/Michaelvilleneuve/react-native-document-scanner

Link manually for android First, we will disable autolink on android , so Edit / Create react-native.config.js at the root of your project

module.exports = {
  dependencies: {
    'react-native-document-scanner': {
      platforms: {
        android: null
      }
    }
  }
};

Now link manually react-native-document-scanner and openCV in your settings.gradle file

include ':react-native-document-scanner'
project(':react-native-document-scanner').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-document-scanner/android')

include ':openCVLibrary310'
project(':openCVLibrary310').projectDir = new File(rootProject.projectDir,'../node_modules/react-native-document-scanner/android/openCVLibrary310')

In android/app/src/main/java/com/your/project/MainActivity.java add

import com.documentscanner.DocumentScannerPackage;

In android/app/src/main/java/com/your/project/MainApplication.java add

import com.documentscanner.DocumentScannerPackage;

In android/app/build.gradle add

dependencies {
    [...]
    compile project(':react-native-document-scanner')
}

The process already described in the readme for iOS works correctly for me.

@obertil Followed your steps (thanks for the same!) for Android and then, it's building without issue. Though, while running the app on android device, I am getting the error "RNPdfScanner was not found in the UIManager". Repeated the steps, but still encountering this issue on Android. On iOS, facing no issues...

May be you forgot to mention some step here?

dheerajk27 avatar Sep 09 '20 14:09 dheerajk27

@obertil Thanks for your solution It works for me, with react-native v0.63.3 I've also upgrade the gradle version for the library as below

For ./node_modules/react-native-document-scanner/android/build.gradle

buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:4.0.1'
    }
}

android {
    compileSdkVersion safeExtGet('compileSdkVersion', 29)
    buildToolsVersion safeExtGet('buildToolsVersion', '29.0.2')
    defaultConfig {
        minSdkVersion safeExtGet('minSdkVersion', 16)
        targetSdkVersion safeExtGet('targetSdkVersion', 29)
    }
}

For ./node_modules/react-native-document-scanner/android/openCVLibrary310/build.gradle

android {
    compileSdkVersion 29
    ...
}

And for ./node_modules/react-native-document-scanner/android/gradle/wrapper/gradle-wrapper.properties

...
distributionUrl=https\://services.gradle.org/distributions/gradle-6.2-all.zip

And a missing step in android/app/src/main/java/com/your/project/MainApplication.java We should add DocumentScannerPackage to our packages in getPackages function:

    @Override
    protected List<ReactPackage> getPackages() {
        @SuppressWarnings("UnnecessaryLocalVariable")
        List<ReactPackage> packages = new PackageList(this).getPackages();
        // Packages that cannot be autolinked yet can be added manually here, for example:
        packages.add(new DocumentScannerPackage());
        return packages;
    }

SiSa68 avatar Nov 10 '20 23:11 SiSa68

in react-native.config.js

dependencies: {
		'react-native-document-scanner': {
			platforms: {
				"android": {
					"packageImportPath": "import com.documentscanner.DocumentScannerPackage;",
					"packageInstance": "new DocumentScannerPackage()"
				}
			}
		},
		"react-native-perspective-image-cropper": {
			platforms: {
				"android": {
					"packageImportPath": "import fr.michaelvilleneuve.customcrop.RNCustomCropPackage;",
					"packageInstance": "new RNCustomCropPackage()"
				}
			}
		}
	}

Hope it will be in repo one day ๐Ÿ˜ž

skv-headless avatar Mar 12 '21 07:03 skv-headless

@skv-headless You saved my day thanks a lot.

laibulle avatar Jun 09 '21 14:06 laibulle

Too late for me, I already migrated to Flutter due to this. But thanks chamo! <3

Gricardov avatar Jun 09 '21 15:06 Gricardov

You dont need to disable link you only need to add the line below to setting.grade

include ':openCVLibrary310'
project(':openCVLibrary310').projectDir = new File(rootProject.projectDir,'../node_modules/@woonivers/react-native-document-scanner/android/openCVLibrary310')

auto link should know that openCVLibrary310 has already been linked and will only add the code to .java

AlenToma avatar Jul 19 '21 01:07 AlenToma