SiriDx / qrcode

A flutter plugin for scanning QR codes. Use AVCaptureSession in iOS and zxing in Android.
MIT License
72 stars 47 forks source link

Divide by zero exception in some devices #5

Closed hfierro closed 4 years ago

hfierro commented 4 years ago

Some devices throw a divide by zero exception, mostly present in Huawei and Samsung devices.

Camera is shown correctly and qr codes are scanned correctly too.

Fatal Exception: java.lang.ArithmeticException: divide by zero at com.journeyapps.barcodescanner.CameraPreview.calculateFrames(CameraPreview.java:389) at com.journeyapps.barcodescanner.CameraPreview.previewSized(CameraPreview.java:461) at com.journeyapps.barcodescanner.CameraPreview.access$300(CameraPreview.java:59) at com.journeyapps.barcodescanner.CameraPreview$3.handleMessage(CameraPreview.java:199) at android.os.Handler.dispatchMessage(Handler.java:108) at android.os.Looper.loop(Looper.java:216) at android.app.ActivityThread.main(ActivityThread.java:7625) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:524) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:987)

kexuebiao commented 4 years ago

Same question

main(1)

java.lang.ArithmeticException

divide by zero

1 com.journeyapps.barcodescanner.j.j(:389)

2 com.journeyapps.barcodescanner.j.b(:461) 3 com.journeyapps.barcodescanner.j.b(:59) 4 com.journeyapps.barcodescanner.f.handleMessage(:199) 5 android.os.Handler.dispatchMessage(Handler.java:108) 6 android.os.Looper.loop(Looper.java:216) 7 android.app.ActivityThread.main(ActivityThread.java:7625) 8 java.lang.reflect.Method.invoke(Native Method) 9 com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:524) 10 com.android.internal.os.ZygoteInit.main(ZygoteInit.java:987)

kexuebiao commented 4 years ago

Huawei MHA AL00 Android 9,level 28

kexuebiao commented 4 years ago

please update android zxing library 'com.journeyapps:zxing-android-embedded:4.1.0'

VytorCalixto commented 4 years ago

I'm seeing this error too in Xiaomi and Motorola devices. Any update?

WasserEsser commented 4 years ago

@VytorCalixto Update the dependency as mentioned above. You can clone the repository, change the build.gradle file to use the latest version (anything above 4.0 will do) and include the package via path in your pubspec.yaml file:

qrcode: path: ./../qrcode/qrcode

instead of

qrcode: ^1.0.4

I did this here: https://github.com/WasserEsser/qrcode

VytorCalixto commented 4 years ago

Thanks @WasserEsser! Do you know why this hasn't been merged to master? Should be an easy PR to fix this issue, right?