deepanrajkumar / react-native-qr-decode-image-camera

Decode react native from gallery and camera
MIT License
35 stars 30 forks source link

Crash on android with gradle 7.0 or above #25

Open vmia159 opened 2 years ago

vmia159 commented 2 years ago

If you are in a newer version of react-native, which will use gradle 7.0 or above.

With older version of barcode-scanning com.google.mlkit:barcode-scanning:16.2.0 it will crash once it find one or more barcode.

Please bump the version to com.google.mlkit:barcode-scanning:17.0.2

And change the import of Barcode from import com.google.mlkit.vision.barcode.Barcode; to import com.google.mlkit.vision.barcode.common.Barcode; as they change the import path of Barcode

Please help to check if these changes breaks when you are still in a older react-native/gradle version.

 diff --git a//Users/vincent/Development/hero-plus-react-native/node_modules/react-native-qr-decode-image-camera/android/src/main/java/com/lewin/qrcode/QRScanReader.java b//Users/vincent/Development/hero-plus-react-native/node_modules/react-native-qr-decode-image-camera/android/src/main/java/com/lewin/qrcode/QRScanReader.java
index e1ae7e8..727c9ac 100644
--- a//Users/vincent/Development/hero-plus-react-native/node_modules/react-native-qr-decode-image-camera/android/src/main/java/com/lewin/qrcode/QRScanReader.java
+++ b//Users/vincent/Development/hero-plus-react-native/node_modules/react-native-qr-decode-image-camera/android/src/main/java/com/lewin/qrcode/QRScanReader.java
@@ -12,7 +12,7 @@ import com.facebook.react.bridge.ReactMethod;
 import com.google.android.gms.tasks.OnFailureListener;
 import com.google.android.gms.tasks.OnSuccessListener;
 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.BarcodeScannerOptions;
 import com.google.mlkit.vision.barcode.BarcodeScanning;
diff --git a/node_modules/react-native-qr-decode-image-camera/android/build.gradle b/node_modules/react-native-qr-decode-image-camera/android/build.gradle
index 4882f81..579f640 100644
--- a/node_modules/react-native-qr-decode-image-camera/android/build.gradle
+++ b/node_modules/react-native-qr-decode-image-camera/android/build.gradle
@@ -57,5 +57,5 @@ repositories {
 dependencies {
     implementation 'com.facebook.react:react-native:+'
     implementation 'com.google.zxing:core:3.4.0'
-    implementation 'com.google.mlkit:barcode-scanning:16.2.0'
+    implementation 'com.google.mlkit:barcode-scanning:17.0.2'
 }
BishalftSaikia commented 1 year ago

this is working for me, noice