AmolGangadhare / flutter_barcode_scanner

Barcode scanner plugin for flutter. Supports barcode scanning for Android and iOS
https://pub.dev/packages/flutter_barcode_scanner
MIT License
385 stars 516 forks source link

[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: MissingPluginException(No implementation found for method scanBarcode on channel flutter_barcode_scanner) #324

Open joselcv opened 1 year ago

joselcv commented 1 year ago

When I try to use the plugin on ios it works however on android I get:

E/flutter (19227): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: MissingPluginException(No implementation found for method scanBarcode on channel flutter_barcode_scanner).

I am using the latest version of flutter and dart to date I don't know if this has something to do with it, and I'm starting the application on a physical device with android version 11

Samsung galaxy a30s

To Reproduce

  1. install the package
  2. in your method: String barcodeScanRes; try { barcodeScanRes = await FlutterBarcodeScanner.scanBarcode( '#33E9FF', 'Cancel', true, ScanMode.QR); VibratorPlugin.checkVibration(); print(barcodeScanRes); } on PlatformException { barcodeScanRes = 'Failed to get platform version.'; }
  3. execute the method.
joselcv commented 1 year ago

I just verified that this error is because in the MainActivity.tk file the class has FlutterFragmentActivity and when it is changed to FlutterActivity it works, however this is a big problem as the other packages like localAuth have been updated and use FlutterFrameActivity, it would be very helpful if you could update the sibling package

This found: import io.flutter.embedding.android.FlutterActivity

class MainActivity: FlutterActivity() { }

but this not: import io.flutter.embedding.android.FlutterFragmentActivity

class MainActivity: FlutterFragmentActivity() { }

joselcv commented 1 year ago

to solve this since I use localAuth and flutterbarcodescanner what I did was that in the file FlutterBarcodeScannerPlugin.java Cambié todas las referencias a flutterActivity a flutterFrameActivity y ahora funciona, sin embargo, cuando presiono cancelar o escaneo un código qr, la consola sigue mostrando constantemente el siguiente mensaje: Camera 1 looking CAMERA_FACING_FRONT state now CAMERA_STATE_CLOSED for client com.samsung.adaptivebrightnessgo API Level 2.

I hope that with all this that I am saying I can contribute so that you can improve the package that is really very useful

abdorizak commented 1 year ago

When I try to use the plugin on ios it works however on android I get:

E/flutter (19227): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: MissingPluginException(No implementation found for method scanBarcode on channel flutter_barcode_scanner).

I am using the latest version of flutter and dart to date I don't know if this has something to do with it, and I'm starting the application on a physical device with android version 11

Samsung galaxy a30s

To Reproduce

  1. install the package
  2. in your method: String barcodeScanRes; try { barcodeScanRes = await FlutterBarcodeScanner.scanBarcode( '#33E9FF', 'Cancel', true, ScanMode.QR); VibratorPlugin.checkVibration(); print(barcodeScanRes); } on PlatformException { barcodeScanRes = 'Failed to get platform version.'; }
  3. execute the method.

did you specify the android minSdkVersion and targetSdkVersion also compileSdkVersion?

itsAyyazdev commented 1 year ago

you can use this one until the fix is merged

flutter_barcode_scanner: git: url: https://github.com/itsAyyazdev/flutter_barcode_scanner.git