zxing-core 3.4.0 crashes on Android < 7.0 when decoding QR code
See original GitHub issueI’m using com.google.zxing:core:3.4.0 with com.google.zxing:android-core:3.3.0 and com.google.zxing:android-integration:3.3.0 in an Android app. Everytime I scan a QR code with an Android device with Android < 7.0 (API 24) the app crashes with the following exception:
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)
at com.google.zxing.qrcode.detector.FinderPatternFinder.selectBestPatterns(FinderPatternFinder.java:616)
at com.google.zxing.qrcode.detector.FinderPatternFinder.find(FinderPatternFinder.java:164)
at com.google.zxing.qrcode.detector.Detector.detect(Detector.java:81)
at com.google.zxing.qrcode.QRCodeReader.decode(QRCodeReader.java:77)
at com.google.zxing.MultiFormatReader.decodeInternal(MultiFormatReader.java:173)
at com.google.zxing.MultiFormatReader.decodeWithState(MultiFormatReader.java:87)
at com.google.zxing.client.android.DecodeHandler.decode(DecodeHandler.java:98)
at com.google.zxing.client.android.DecodeHandler.handleMessage(DecodeHandler.java:59)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at com.google.zxing.client.android.DecodeThread.run(DecodeThread.java:112)
It looks like the java.util.List.sort(…) method used in FinderPatternFinder.java:616 is not available on Android < API 24: https://developer.android.com/reference/java/util/List.html#sort(java.util.Comparator<?%2520super%2520E>)
Proposed solution: Use Collections.sort(possibleCenters, moduleComparator)
instead of possibleCenters.sort(moduleComparator);
To make things more complicated: Android support for Java8 depends on the Android version. Some language features might be only available on newer Android versions: https://developer.android.com/studio/write/java8-support Requiring Java8 for zxing-core means either checking all used Java8 features if they are available Android < 7.0 or dropping support for Android < 7.0 completely.
Issue Analytics
- State:
- Created 4 years ago
- Comments:30 (13 by maintainers)
Top GitHub Comments
Resolved in https://github.com/zxing/zxing/commit/4b573da62a175a16c59ef52df55edf08a413f4bf by just using the older library version.
But you’re surely aware that a LOT of other apps besides the one you’re talking about (and of which nobody really cares) depended on your library. Maybe you don’t see it as a bug, but yes, it sucks, and I am also looking for a replacemente due to this.