Java 11+ APIs available through desugaring

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)
  • public IOException getCause()

Fully implemented class.
 

java.lang


 Iterable


  • public void forEach(Consumer action)
  • public java.util.Spliterator spliterator()

Additional methods on existing class.
 

java.time
See customizations

 Clock


  • protected Clock()
  • public boolean equals(Object obj)
  • public static Clock fixed(
     Instant fixedInstant, ZoneId zone)
  • public abstract ZoneId getZone()
  • public int hashCode()
  • public abstract Instant instant()
  • public long millis()
  • public static Clock offset(
     Clock baseClock, Duration offsetDuration)
  • public static Clock system(ZoneId zone)
  • public static Clock systemDefaultZone()
  • public static Clock systemUTC()
  • public static Clock tick(
     Clock baseClock, Duration tickDuration)
  • public static Clock tickMillis(
     ZoneId zone)2
  • public static Clock tickMinutes(ZoneId zone)
  • public static Clock tickSeconds(ZoneId zone)
  • public abstract Clock withZone(ZoneId p0)

2 Not present in Android T (May not resolve at compilation).
 

java.time
See customizations

 DateTimeException


  • public DateTimeException(String message)
  • public DateTimeException(
     String message, Throwable cause)

Fully implemented class.
 

java.time
See customizations

 DayOfWeek


  • public static final DayOfWeek FRIDAY
  • public static final DayOfWeek MONDAY
  • public static final DayOfWeek SATURDAY
  • public static final DayOfWeek SUNDAY
  • public static final DayOfWeek THURSDAY
  • public static final DayOfWeek TUESDAY
  • public static final DayOfWeek WEDNESDAY
  • public Temporal adjustInto(Temporal temporal)
  • public static DayOfWeek from(
     TemporalAccessor temporal)
  • public int get(TemporalField field)
  • public String getDisplayName(
     TextStyle style, java.util.Locale locale)
  • public long getLong(TemporalField field)
  • public int getValue()
  • public boolean isSupported(TemporalField field)
  • public DayOfWeek minus(long days)
  • public static DayOfWeek of(int dayOfWeek)
  • public DayOfWeek plus(long days)
  • public Object query(TemporalQuery query)
  • public ValueRange range(TemporalField field)
  • public static DayOfWeek valueOf(String name)
  • public static DayOfWeek[] values()

Fully implemented class.
 

java.time
See customizations

 Duration


  • public static final Duration ZERO
  • public Duration abs()
  • public Temporal addTo(Temporal temporal)
  • public static Duration between(
     Temporal startInclusive, Temporal endExclusive)
  • public int compareTo(Duration otherDuration)
  • public long dividedBy(Duration divisor)
  • public Duration dividedBy(long divisor)
  • public boolean equals(Object otherDuration)
  • public static Duration from(TemporalAmount amount)
  • public long get(TemporalUnit unit)
  • public int getNano()
  • public long getSeconds()
  • public java.util.List getUnits()
  • public int hashCode()
  • public