Java 11+ APIs available through desugaring
Stay organized with collections
Save and categorize content based on your preferences.
Android Studio includes support for using a number of Java 11+ APIs without
requiring a minimum API level for your app. This means that if you use an API
introduced in Android 13 (API level 33) the code also works on all previous
versions. Most APIs introduced to Android over the years are supported on
Android 13. Through a process called
API desugaring, the DEX
compiler (D8) allows you to include more standard language APIs in apps that
support older versions of Android.
Java 11 support API desugaring comes in three flavors:
The minimal version includes
only the java.util.function package and replacement classes for some Android
framework concurrent collections that have known issues on old devices.
The default version is
effectively an upgraded version of the Java 8 API desugaring updated to
Java 11. It includes the java.time and java.util.stream packages in
addition to everything in the minimal version.
The nio version includes the
java.nio package in addition to everything in the default version.
The following searchable table shows which Java 11+ libraries are available when
you use the latest version of the Android Gradle plugin with the
coreLibraryDesugaring dependency set to
com.android.tools:desugar_jdk_libs:2.0.1 (see
API desugaring
for more information). Set this property in the build.gradle or
build.gradle.kts file.
Package + Class, Enum, or Interface
Constructors, Properties, and Methods
Notes
java.io
BufferedReader
public java.util.stream.Stream lines()
Additional methods on existing class.
java.io
UncheckedIOException
public UncheckedIOException(IOException cause)
public UncheckedIOException( String message, IOException cause)