From 3ede7ac8f019cd679be2006e931890f30a05975b Mon Sep 17 00:00:00 2001 From: Carter Jernigan Date: Tue, 9 Nov 2021 13:53:20 -0500 Subject: [PATCH] [#59] Enable core library desugaring for app module Note that if we want to run tests from each module on older Android versions, we would need to enable desugaring for each module that is using newer JDK features. For now, this prevents the app itself from crashing on devices with older versions of Android --- app/build.gradle.kts | 6 ++++++ gradle.properties | 1 + settings.gradle.kts | 2 ++ 3 files changed, 9 insertions(+) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 58a6a200..ce4d7561 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -15,6 +15,10 @@ android { versionName = "1.0" } + compileOptions { + isCoreLibraryDesugaringEnabled = true + } + flavorDimensions.add("network") productFlavors { @@ -76,6 +80,8 @@ android { } dependencies { + coreLibraryDesugaring(libs.desugaring) + implementation(libs.androidx.activity) implementation(libs.androidx.annotation) implementation(libs.androidx.core) diff --git a/gradle.properties b/gradle.properties index ef41e006..298cf149 100644 --- a/gradle.properties +++ b/gradle.properties @@ -65,6 +65,7 @@ ANDROIDX_TEST_VERSION=1.4.1-alpha03 ANDROIDX_TEST_JUNIT_VERSION=1.1.3 ANDROIDX_TEST_ORCHESTRATOR_VERSION=1.4.1-alpha03 ANDROIDX_UI_AUTOMATOR_VERSION=2.2.0-alpha1 +CORE_LIBRARY_DESUGARING_VERSION=1.1.5 GOOGLE_MATERIAL_VERSION=1.4.0 JACOCO_VERSION=0.8.7 KOTLINX_COROUTINES_VERSION=1.5.2 diff --git a/settings.gradle.kts b/settings.gradle.kts index c0b8ea19..9bfcf61f 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -59,6 +59,7 @@ dependencyResolutionManagement { val androidxTestVersion = extra["ANDROIDX_TEST_VERSION"].toString() val androidxUiAutomatorVersion = extra["ANDROIDX_UI_AUTOMATOR_VERSION"].toString() val androidxSecurityCryptoVersion = extra["ANDROIDX_SECURITY_CRYPTO_VERSION"].toString() + val coreLibraryDesugaringVersion = extra["CORE_LIBRARY_DESUGARING_VERSION"].toString() val googleMaterialVersion = extra["GOOGLE_MATERIAL_VERSION"].toString() val jacocoVersion = extra["JACOCO_VERSION"].toString() val javaVersion = extra["ANDROID_JVM_TARGET"].toString() @@ -86,6 +87,7 @@ dependencyResolutionManagement { alias("androidx-lifecycle-livedata").to("androidx.lifecycle:lifecycle-livedata-ktx:$androidxLifecycleVersion") alias("androidx-security-crypto").to("androidx.security:security-crypto-ktx:$androidxSecurityCryptoVersion") alias("androidx-viewmodel-compose").to("androidx.lifecycle:lifecycle-viewmodel-compose:$androidxLifecycleVersion") + alias("desugaring").to("com.android.tools:desugar_jdk_libs:$coreLibraryDesugaringVersion") alias("google-material").to("com.google.android.material:material:$googleMaterialVersion") alias("kotlin").to("org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlinVersion") alias("kotlinx-coroutines-android").to("org.jetbrains.kotlinx:kotlinx-coroutines-android:$kotlinxCoroutinesVersion")