Open fciprian42 opened 2 years ago
Same issue
@fciprian42 or @mohshafie, I'm having the same issue, did you find a workaround?
Hi again! Just realized that if I remove the vision-camera-ocr
package, it starts to work. But I want both, so that is not an option for me, but it might give some clues. I'll Investigate further.
I found a fix:
In vision-camera-ocr
I changed the mlkit version:
From:
implementation 'com.google.android.gms:play-services-mlkit-text-recognition:18.0.0'
To:
implementation 'com.google.mlkit:text-recognition:16.0.0-beta6'
And in vision-camera-code-scanner
I changed the mlkit version:
From:
implementation 'com.google.mlkit:barcode-scanning:17.0.0'
To:
implementation 'com.google.mlkit:barcode-scanning:17.0.2'
common
namespace.Patch files: vision-camera-ocr:
diff --git a/node_modules/vision-camera-ocr/android/build.gradle b/node_modules/vision-camera-ocr/android/build.gradle
index 6d81d85..e966f0f 100644
--- a/node_modules/vision-camera-ocr/android/build.gradle
+++ b/node_modules/vision-camera-ocr/android/build.gradle
@@ -129,6 +129,6 @@ dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation project(':react-native-vision-camera')
- implementation 'com.google.android.gms:play-services-mlkit-text-recognition:18.0.0'
+ implementation 'com.google.mlkit:text-recognition:16.0.0-beta6'
implementation "androidx.camera:camera-core:1.1.0-alpha08"
}
vision-camera-code-scanner:
diff --git a/node_modules/vision-camera-code-scanner/android/build.gradle b/node_modules/vision-camera-code-scanner/android/build.gradle
index b6bd964..4829f31 100644
--- a/node_modules/vision-camera-code-scanner/android/build.gradle
+++ b/node_modules/vision-camera-code-scanner/android/build.gradle
@@ -57,5 +57,5 @@ dependencies {
implementation "com.facebook.react:react-native:+" // From node_modules
api project(":react-native-vision-camera")
implementation "androidx.camera:camera-core:1.1.0-alpha06"
- implementation 'com.google.mlkit:barcode-scanning:17.0.0'
+ implementation 'com.google.mlkit:barcode-scanning:17.0.2'
}
diff --git a/node_modules/vision-camera-code-scanner/android/src/main/java/com/visioncameracodescanner/BarcodeConverter.java b/node_modules/vision-camera-code-scanner/android/src/main/java/com/visioncameracodescanner/BarcodeConverter.java
index 74e208b..eb4ed07 100644
--- a/node_modules/vision-camera-code-scanner/android/src/main/java/com/visioncameracodescanner/BarcodeConverter.java
+++ b/node_modules/vision-camera-code-scanner/android/src/main/java/com/visioncameracodescanner/BarcodeConverter.java
@@ -7,7 +7,7 @@ import androidx.annotation.NonNull;
import com.facebook.react.bridge.WritableNativeArray;
import com.facebook.react.bridge.WritableNativeMap;
-import com.google.mlkit.vision.barcode.Barcode;
+import com.google.mlkit.vision.barcode.common.Barcode;
import java.util.List;
diff --git a/node_modules/vision-camera-code-scanner/android/src/main/java/com/visioncameracodescanner/VisionCameraCodeScannerPlugin.java b/node_modules/vision-camera-code-scanner/android/src/main/java/com/visioncameracodescanner/VisionCameraCodeScannerPlugin.java
index 8198564..a3adafd 100644
--- a/node_modules/vision-camera-code-scanner/android/src/main/java/com/visioncameracodescanner/VisionCameraCodeScannerPlugin.java
+++ b/node_modules/vision-camera-code-scanner/android/src/main/java/com/visioncameracodescanner/VisionCameraCodeScannerPlugin.java
@@ -24,7 +24,7 @@ import androidx.camera.core.ImageProxy;
import com.google.android.gms.tasks.Tasks;
import com.mrousavy.camera.frameprocessor.FrameProcessorPlugin;
import com.google.android.gms.tasks.Task;
-import com.google.mlkit.vision.barcode.Barcode;
+import com.google.mlkit.vision.barcode.common.Barcode;
import com.google.mlkit.vision.barcode.BarcodeScanner;
import com.google.mlkit.vision.barcode.BarcodeScanning;
import com.google.mlkit.vision.barcode.BarcodeScannerOptions;
Hi, We meet an issue in our react native project on Android only, for IOS it's work perfectly We use both package in the project
vision-camera-ocr
andvision-camera-code-scanner
and the recognition with codes dont work, yet I see no android config on the package git I show you the logs :ERROR Frame Processor threw an error: Exception in HostFunction: java.lang.VerifyError: Verifier rejected class com.google.mlkit.vision.barcode.BarcodeScanning: com.google.mlkit.vision.barcode.BarcodeScanner com.google.mlkit.vision.barcode.BarcodeScanning.getClient() failed to verify: com.google.mlkit.vision.barcode.BarcodeScanner com.google.mlkit.vision.barcode.BarcodeScanning.getClient(): [0x10] can't resolve returned type 'Unresolved Reference: com.google.mlkit.vision.barcode.BarcodeScanner' or 'Unresolved Reference: com.google.mlkit.vision.barcode.internal.BarcodeScannerImpl' com.google.mlkit.vision.barcode.BarcodeScanner com.google.mlkit.vision.barcode.BarcodeScanning.getClient(com.google.mlkit.vision.barcode.BarcodeScannerOptions) failed to verify: com.google.mlkit.vision.barcode.BarcodeScanner com.google.mlkit.vision.barcode.BarcodeScanning.getClient(com.google.mlkit.vision.barcode.BarcodeScannerOptions): [0x15] can't resolve returned type 'Unresolved Reference: com.google.mlkit.vision.barcode.BarcodeScanner' or 'Unresolved Reference: com.google.mlkit.vision.barcode.internal.BarcodeScannerImpl' (declaration of 'com.google.mlkit.vision.barcode.BarcodeScanning' appears in /data/app/~~6fE0Vr3mVUJ9FiENpm0w5w==/com.neurowaste.nwglobal.global-Es6qHUrtm-hLZ31btXlOcQ==/base.apk!classes6.dex)
orERROR Frame Processor threw an error: Exception in HostFunction: java.lang.NoClassDefFoundError: com.google.mlkit.vision.barcode.BarcodeScanning
There is our build.gradle :
buildscript { ext { buildToolsVersion = "30.0.2" minSdkVersion = 21 compileSdkVersion = 31 targetSdkVersion = 31 ndkVersion = "21.4.7075529" googlePlayServicesVersion = "17.0.0" } repositories { google() mavenCentral() } dependencies { classpath("com.android.tools.build:gradle:4.2.2") classpath 'com.google.gms:google-services:4.3.10' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } }
The package version is 0.2.0 and 2.13.3 for
react-native-vision-camera
I use the code above for run the detection (I've tried both versions prupose on the git)
const frameProcessor = useFrameProcessor(frame => { 'worklet'; const detectedBarcodes = scanBarcodes(frame, [BarcodeFormat.ALL_FORMATS], { checkInverted: true, }); runOnJS(setCodes)(detectedBarcodes); }, []);
The problem occur when with try to scan on android.. If anyone have a clue or something! Thanks