juliuscanute / qr_code_scanner

QR Code Scanner for Flutter
BSD 2-Clause "Simplified" License
999 stars 759 forks source link

0.7.0 cause app close on Android 6.x but 0.6.1 works #509

Closed JmyW closed 2 years ago

JmyW commented 2 years ago

Hi The ver. 0.7.0 is not working on Android 6.x. I have two Android 6.x phones, both failed with 0.7.0 but work with 0.6.1. And I also tried on Android 11, both 0.7.0 and 0.6.1 works fine.

Error symptom:

flutter doctor -v: Flutter assets will be downloaded from https://storage.flutter-io.cn. Make sure you trust this source! [√] Flutter (Channel stable, 2.10.3, on Microsoft Windows [Version 10.0.22000.527], locale zh-TW) • Flutter version 2.10.3 at C:\flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision 7e9793dee1 (5 days ago), 2022-03-02 11:23:12 -0600 • Engine revision bd539267b4 • Dart version 2.16.1 • DevTools version 2.9.2 • Pub download mirror https://pub.flutter-io.cn • Flutter download mirror https://storage.flutter-io.cn

[√] Android toolchain - develop for Android devices (Android SDK version 30.0.3) • Android SDK at C:\Users\Jemmy_Wu\AppData\Local\Android\Sdk • Platform android-31, build-tools 30.0.3 • ANDROID_HOME = C:\Users\Jemmy_Wu\AppData\Local\Android\Sdk • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java • Java version OpenJDK Runtime Environment (build 11.0.11+9-b60-7590822) • All Android licenses accepted.

[√] Chrome - develop for the web • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[√] Visual Studio - develop for Windows (Visual Studio Community 2019 16.10.0) • Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2019\Community • Visual Studio Community 2019 version 16.10.31321.278 • Windows 10 SDK version 10.0.19041.0

[√] Android Studio (version 2021.1) • Android Studio at C:\Program Files\Android\Android Studio • Flutter plugin can be installed from: https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 11.0.11+9-b60-7590822)

[√] Connected device (3 available) • Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.22000.527] • Chrome (web) • chrome • web-javascript • Google Chrome 99.0.4844.51 • Edge (web) • edge • web-javascript • Microsoft Edge 98.0.1108.56

[√] HTTP Host Availability • All required HTTP hosts are available

• No issues found!

juliansteenbakker commented 2 years ago

Thanks for reporting. I can reproduce it myself and am working on a solution.

juliansteenbakker commented 2 years ago

Can you please try it in a virtual device running android 6? I thought i could reproduce it, but as it turns out there was a problem with my device. When i try it in a virtual device everything is working without a problem. Also, do you have some error log for me?

JmyW commented 2 years ago

The failure wasn't happened when camera preview. But FATAL EXCEPTION as soon as the camera detects a qr-code.

It's the same failure on real device and simulator of Android 6.0. (just test the android 6 simulator that links the camera to my laptop camera)

Both have the same logs as following:

E/AndroidRuntime(25569): FATAL EXCEPTION: DecoderThread E/AndroidRuntime(25569): Process: com.jmytech.kindtch, PID: 25569 E/AndroidRuntime(25569): java.lang.NoSuchMethodError: No interface method sort(Ljava/util/Comparator;)V in class Ljava/util/List; or its super classes (declaration of 'java.util.List' appears in /system/framework/core-libart.jar) E/AndroidRuntime(25569): at com.google.zxing.qrcode.detector.FinderPatternFinder.selectBestPatterns(FinderPatternFinder.java:624) E/AndroidRuntime(25569): at com.google.zxing.qrcode.detector.FinderPatternFinder.find(FinderPatternFinder.java:164) E/AndroidRuntime(25569): at com.google.zxing.qrcode.detector.Detector.detect(Detector.java:81) E/AndroidRuntime(25569): at com.google.zxing.qrcode.QRCodeReader.decode(QRCodeReader.java:77) E/AndroidRuntime(25569): at com.google.zxing.MultiFormatReader.decodeInternal(MultiFormatReader.java:173) E/AndroidRuntime(25569): at com.google.zxing.MultiFormatReader.decodeWithState(MultiFormatReader.java:87) E/AndroidRuntime(25569): at com.journeyapps.barcodescanner.Decoder.decode(Decoder.java:75) E/AndroidRuntime(25569): at com.journeyapps.barcodescanner.Decoder.decode(Decoder.java:49) E/AndroidRuntime(25569): at com.journeyapps.barcodescanner.DecoderThread.decode(DecoderThread.java:146) E/AndroidRuntime(25569): at com.journeyapps.barcodescanner.DecoderThread.access$000(DecoderThread.java:22) E/AndroidRuntime(25569): at com.journeyapps.barcodescanner.DecoderThread$1.handleMessage(DecoderThread.java:38) E/AndroidRuntime(25569): at android.os.Handler.dispatchMessage(Handler.java:98) E/AndroidRuntime(25569): at android.os.Looper.loop(Looper.java:168) E/AndroidRuntime(25569): at android.os.HandlerThread.run(HandlerThread.java:61) D/CameraPreview(25569): pause() I/SensorManager(25569): unregisterListenerImpl++: listener = android.view.OrientationEventListener$SensorEventListenerImpl@6cd55fc D/CameraInstance(25569): Closing camera

declanwoods commented 2 years ago

Caused by zxing 3.3.3 -> 3.4.1 upgrade as part of 0.7.0. ArrayList.sort requires SDK 24.

https://github.com/juliuscanute/qr_code_scanner/compare/0.6.1..0.7.0#diff-197b190e4a3512994d2cebed8aff5479ff88e136b8cc7a4b148ec9c3945bd65aR54

https://stackoverflow.com/a/58040877/3150562

Can fix by downgrading or enabling coreLibraryDesugaringEnabled

JmyW commented 2 years ago

Thank you so much! Yes, coreLibraryDesugaringEnabled solved it. 👍👍👍