question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

zxing-core 3.4.0 crashes on Android < 7.0 when decoding QR code

See original GitHub issue

I’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:closed
  • Created 4 years ago
  • Comments:30 (13 by maintainers)

github_iconTop GitHub Comments

13reactions
srowencommented, May 22, 2019

Resolved in https://github.com/zxing/zxing/commit/4b573da62a175a16c59ef52df55edf08a413f4bf by just using the older library version.

11reactions
adriancretucommented, Jun 5, 2019

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Android QR Code Scanning Using Zxing Library Turns Into ...
The problem is that you have copied and pasted all of our android/ code into your project, and don't really understand what you've...
Read more >
embarkmobile - Bountysource
Dear Zxing-Android-Embedded-Team,. I'm using your QR-Code-Scanner to scan some QR-codes in some of our apps. If I use the QR-Code-Reader inside a ...
Read more >
QR-Code generator crashes because of Unicode.
QR-Code generator crashes because of Unicode. Bug #929001 reported by Steve on 2012-02-08. 6.
Read more >
zxing-android-embedded | Barcode scanner library for Android
Barcode scanning library for Android, using ZXing for decoding. The project is loosely based on the ZXing Android Barcode Scanner application, ...
Read more >
Journeyappszxing - dermamiblog.de
Qrcode Zxing Com.journeyapps Zxing-android-embedded 3.4.0 Tutorial . ... Developer Software website online barcode decoder from the zxing project N/A This ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found