Skip to content

Java8+ / Android API Level < 26 Support¶

If your app supports devices with an API level below 26, newer Java 8 features must be included in the build process ("desugaring").

To do this, the Gradle Build Configuration of the application must be modified as follows:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
android {
    defaultConfig {
        // Required when setting minSdkVersion to 20 or lower
        multiDexEnabled true
    }

    compileOptions {
        // Flag to enable support for the new language APIs
        coreLibraryDesugaringEnabled true
        // Sets Java compatibility to Java 8
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {
    coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5'
}

More information and the latest version of the Desugaring library can be found in the official Android Developer documentation: https://developer.android.com/studio/write/java8-support


Last update: January 7, 2022