From cbcf1bcd998b9a5fdf7354a4287c64e95f2c3845 Mon Sep 17 00:00:00 2001 From: Sylvia van Os Date: Wed, 28 Jul 2021 23:05:27 +0200 Subject: [PATCH] Use desugaring to upgrade zxing without having to increase minSdk As documented by the zxing team on https://github.com/zxing/zxing/wiki/Frequently-Asked-Questions#it-doesnt-work-with-java-7--no-interface-method-sortljavautilcomparator --- app/build.gradle | 10 +++++++--- .../card_locker/LoyaltyCardLockerApplication.java | 5 ++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index fdcbebb7c8..e647e51de6 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -22,6 +22,7 @@ android { versionName "2.0.4" vectorDrawables.useSupportLibrary true + multiDexEnabled true } buildTypes { @@ -38,6 +39,10 @@ android { compileOptions { encoding "UTF-8" + + // Flag to enable support for the new language APIs + coreLibraryDesugaringEnabled true + sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } @@ -74,12 +79,11 @@ dependencies { implementation 'androidx.constraintlayout:constraintlayout:2.0.4' implementation 'androidx.preference:preference:1.1.1' implementation 'com.google.android.material:material:1.4.0' + coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5' // Third-party implementation 'com.journeyapps:zxing-android-embedded:4.1.0@aar' - // Do not upgrade past 3.3.3! Causes a crash on versions before Android Nougat - //noinspection GradleDependency - implementation 'com.google.zxing:core:3.3.3' + implementation 'com.google.zxing:core:3.4.1' implementation 'org.apache.commons:commons-csv:1.8' implementation 'com.jaredrummler:colorpicker:1.1.0' implementation 'com.google.guava:guava:30.1.1-jre' diff --git a/app/src/main/java/protect/card_locker/LoyaltyCardLockerApplication.java b/app/src/main/java/protect/card_locker/LoyaltyCardLockerApplication.java index 43d950cc0d..4765f6fc99 100644 --- a/app/src/main/java/protect/card_locker/LoyaltyCardLockerApplication.java +++ b/app/src/main/java/protect/card_locker/LoyaltyCardLockerApplication.java @@ -1,11 +1,10 @@ package protect.card_locker; -import android.app.Application; - import androidx.appcompat.app.AppCompatDelegate; +import androidx.multidex.MultiDexApplication; import protect.card_locker.preferences.Settings; -public class LoyaltyCardLockerApplication extends Application { +public class LoyaltyCardLockerApplication extends MultiDexApplication { public void onCreate() { super.onCreate();