From b78bd5c5f14b8cc4f6878f894c107e3eae97e6eb Mon Sep 17 00:00:00 2001 From: Kevin Gorham Date: Wed, 26 May 2021 10:04:47 -0400 Subject: [PATCH] Fix: QR scanning issues on API below 24. This had to do with the zebra crossing (zxing) library using a Java 8 sorted API that is not available until Android API 24. The previous fix was to revert to an older version of zxing but now R8/D8 allows for desugaring so that the sort API now works. --- app/build.gradle | 4 ++++ app/src/main/java/cash/z/ecc/android/ui/scan/QrAnalyzer.kt | 1 + 2 files changed, 5 insertions(+) diff --git a/app/build.gradle b/app/build.gradle index 76bab01..4ff69c6 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -78,6 +78,8 @@ android { } } compileOptions { + // emable support for new langauge APIs but also fix the issue with zxing on API < 24 + coreLibraryDesugaringEnabled true sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } @@ -146,6 +148,8 @@ dependencies { implementation Deps.AndroidX.Navigation.UI_KTX implementation Deps.AndroidX.Room.ROOM_KTX kapt Deps.AndroidX.Room.ROOM_COMPILER + coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5' + // Google implementation Deps.Google.GUAVA diff --git a/app/src/main/java/cash/z/ecc/android/ui/scan/QrAnalyzer.kt b/app/src/main/java/cash/z/ecc/android/ui/scan/QrAnalyzer.kt index 1e3a982..66bee5d 100644 --- a/app/src/main/java/cash/z/ecc/android/ui/scan/QrAnalyzer.kt +++ b/app/src/main/java/cash/z/ecc/android/ui/scan/QrAnalyzer.kt @@ -44,6 +44,7 @@ class QrAnalyzer(val scanCallback: (qrContent: String, image: ImageProxy) -> Uni null } catch (e: Throwable) { twig("Error while scanning QR: $e") + twig(e) null } }