capacitor-community / barcode-scanner

A fast and efficient (QR) barcode scanner for Capacitor
MIT License
436 stars 172 forks source link

Error with BarcodeScanner.stop() on Android #239

Closed loicparent closed 1 year ago

loicparent commented 1 year ago

Describe the bug The app crash after the calling the method BarcodeScanner.stop()

To Reproduce Steps to reproduce the behavior:

  1. Install a new ionic project with Capacitor
  2. Install the package barcode-scanner + configs
  3. Create a new modal and adapt styles to display the scanner
  4. On scan success, call the method BarcodeScanner.stop()
  5. Run the app on an Android device using Android Studio.
  6. The app crash and I can see the error in the Android Studio App.

Error Message

FATAL EXCEPTION: main
Process: io.ionic.starter, PID: 28914
java.lang.NullPointerException: Attempt to invoke virtual method 'void com.getcapacitor.PluginCall.resolve(com.getcapacitor.JSObject)' on a null object reference
    at com.getcapacitor.community.barcodescanner.CapacitorCommunityBarcodeScanner$3.onSuccess(CapacitorCommunityBarcodeScanner.java:342)
    at com.getcapacitor.community.barcodescanner.CapacitorCommunityBarcodeScanner$3.onSuccess(CapacitorCommunityBarcodeScanner.java:304)
    at com.google.android.gms.tasks.zzm.run(com.google.android.gms:play-services-tasks@@18.0.2:1)
    at android.os.Handler.handleCallback(Handler.java:942)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loopOnce(Looper.java:226)
    at android.os.Looper.loop(Looper.java:313)
    at android.app.ActivityThread.main(ActivityThread.java:8757)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067)

Expected behavior The scanner stop working without crashing the app.

Version

Smartphone (please complete the following information):

loicparent commented 1 year ago

Also, the command to run the app on IOS (ionic cap run ios --open) cause issue too. After rolling back to the version 4.0.1 (and adapted the code), it works fine.

thegnuu commented 1 year ago

stop might be possible, especially if it is not started or something, I need to check this out.

The other problem with cap run works on my device, might be something with the xcode cache or something, I am not able to reproduce this one...

Jopie01 commented 1 year ago

The error seems a duplicate of #195

thegnuu commented 1 year ago

Found the issue and it should be fixed in 5.0.0-beta.2. But I still need to verify if the same might happen on iOS :)

loicparent commented 1 year ago

Hi @thegnuu,

Thanks for the reply! I finally rollback to the version 4.0.1 that works fine. I will check the new version later :)

Kind regards, Loïc

liuwin7 commented 11 months ago

@thegnuu Where to find the version, beta 2 ? Nothings from npmjs.org