Skip to content

Commit

Permalink
Desugar Java 8 language features for ZXing 3.4
Browse files Browse the repository at this point in the history
Add desugaring support to reverse translate Java 8 language features
in order to use the latest ZXing without having to increase minSdk.

ZXing 3.4 doesn't work on SDK levels below 24 anymore, see:
zxing/zxing#1170

Many thanks to @TheLastProject for showing me the way:
CatimaLoyalty/Android@cbcf1bc
  • Loading branch information
markusfisch committed Mar 16, 2022
1 parent e6e9b91 commit 867dc36
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
15 changes: 12 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ android {
versionCode 93
versionName '1.48.1'

// Required for desugaring.
multiDexEnabled true

// It's recommended to set this value to the lowest API level
// able to provide all the functionality.
renderscriptTargetApi 24
Expand Down Expand Up @@ -61,6 +64,13 @@ android {
}
}

compileOptions {
// To desugar fancy Java features in ZXing 3.4.+ that don't
// work on SDK < 24. See:
// https://github.com/zxing/zxing/issues/1170
coreLibraryDesugaringEnabled true
}

lintOptions {
// Because at the time of writing, even the latest version
// of RenderScript is raising this error no matter if
Expand All @@ -78,15 +88,14 @@ dependencies {
}
testImplementation 'junit:junit:4.13.2'

coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5'
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.2"
implementation "com.android.support:appcompat-v7:$support_version"
implementation "com.android.support:design:$support_version"
implementation "com.android.support:preference-v7:$support_version"
implementation "com.android.support:preference-v14:$support_version"
// Do NOT upgrade ZXing because newer versions won't work on API < 24
// https://github.com/zxing/zxing/issues/1170
implementation 'com.google.zxing:core:3.3.3'
implementation 'com.google.zxing:core:3.4.1'
implementation 'com.github.markusfisch:CameraView:1.9.1'
implementation 'com.github.markusfisch:ScalingImageView:1.3.0'
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package de.markusfisch.android.binaryeye.app

import android.app.Application
import android.support.multidex.MultiDexApplication;
import android.support.v8.renderscript.RenderScript
import de.markusfisch.android.binaryeye.database.Database
import de.markusfisch.android.binaryeye.preference.Preferences

val db = Database()
val prefs = Preferences()

class BinaryEyeApp : Application() {
class BinaryEyeApp : MultiDexApplication() {
override fun onCreate() {
super.onCreate()
db.open(this)
Expand Down

0 comments on commit 867dc36

Please sign in to comment.