android build_error ai_generated true

Error: Default interface methods are only supported starting with Android 7.0 (API 24)

ID: android/desugaring-error

Also available as: JSON · Markdown
92%Fix Rate
92%Confidence
3Evidence
2023-01-01First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
8 active

Root Cause

Java 8+ features used but desugaring not enabled. minSdk too low or compileOptions missing.

generic

Workarounds

  1. 95% success Enable Java 8 desugaring in build.gradle
    android { compileOptions { sourceCompatibility JavaVersion.VERSION_1_8; targetCompatibility JavaVersion.VERSION_1_8 } }

    Sources: https://developer.android.com/build/

  2. 88% success Enable core library desugaring for java.time and streams on older APIs
    android { compileOptions { coreLibraryDesugaringEnabled true } }; dependencies { coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.4' }
  3. 85% success Set Kotlin JVM target to 1.8
    kotlinOptions { jvmTarget = '1.8' }

Dead Ends

Common approaches that don't work:

  1. Raise minSdk to 26+ to support all Java 8 features 70% fail

    Excludes older devices. Enable desugaring instead to support Java 8 on all API levels.

  2. Rewrite code to avoid Java 8 features (lambdas, default methods) 82% fail

    Unnecessary; Android toolchain supports desugaring to convert these to older bytecode