Java 11+ APIs available through desugaring with the minimal specification

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_minimal: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.util.concurrent

ConcurrentHashMap.
 KeySetView

  • public boolean add(Object e)
  • public boolean addAll(Collection c)
  • public boolean contains(Object o)
  • public boolean equals(Object o)
  • public void forEach(Consumer action)
  • public Object getMappedValue()
  • public int hashCode()
  • public Iterator iterator()
  • public boolean remove(Object o)
  • public Spliterator spliterator()

Some methods (8) present in Android T are not supported.

java.util.concurrent

ConcurrentHashMap

  • public ConcurrentHashMap()
  • public ConcurrentHashMap(int initialCapacity)
  • public ConcurrentHashMap(
     int initialCapacity, float loadFactor)
  • public ConcurrentHashMap(
      int initialCapacity,
      float loadFactor,
      int concurrencyLevel)
  • public ConcurrentHashMap(Map m)
  • public void clear()
  • public Object compute(
     Object key, BiFunction remappingFunction)
  • public Object computeIfAbsent(
     Object key, Function mappingFunction)
  • public Object computeIfPresent(
     Object key, BiFunction remappingFunction)
  • public boolean contains(Object value)
  • public boolean containsKey(Object key)
  • public boolean containsValue(Object value)
  • public Enumeration elements()
  • public Set entrySet()
  • public boolean equals(Object o)
  • public void forEach(
     long parallelismThreshold, BiConsumer action)
  • public void forEach(
      long parallelismThreshold,
      BiFunction transformer,
      Consumer action)
  • public void forEach(BiConsumer action)
  • public void forEachEntry(
     long parallelismThreshold, Consumer action)
  • public void forEachEntry(
      long parallelismThreshold,
      Function transformer,
      Consumer action)
  • public void forEachKey(
     long parallelismThreshold, Consumer action)
  • public void forEachKey(
      long parallelismThreshold,
      Function transformer,
      Consumer action)
  • public void forEachValue(
     long parallelismThreshold, Consumer action)
  • public void forEachValue(
      long parallelismThreshold,
      Function transformer,
      Consumer action)
  • public Object get(Object key)
  • public Object getOrDefault(
     Object key, Object defaultValue)
  • public int hashCode()
  • public boolean isEmpty()
  • public Set keySet()
  • public ConcurrentHashMap.KeySetView keySet(
     Object mappedValue)
  • public Enumeration keys()
  • public long mappingCount()
  • public Object merge(
      Object key,
      Object value,
      BiFunction remappingFunction)
  • public static ConcurrentHashMap.KeySetView newKeySet()
  • public static ConcurrentHashMap.KeySetView newKeySet(
     int initialCapacity)
  • public Object put(Object key, Object value)
  • public void putAll(Map m)
  • public Object putIfAbsent(Object key, Object value)
  • public Object reduce(
      long parallelismThreshold,
      BiFunction transformer,
      BiFunction reducer)
  • public Object reduceEntries(
      long parallelismThreshold,
      Function transformer,
      BiFunction reducer)
  • public Map.Entry reduceEntries(
     long parallelismThreshold, BiFunction reducer)
  • public double reduceEntriesToDouble(
      long parallelismThreshold,
      ToDoubleFunction transformer,
      double basis,
      DoubleBinaryOperator reducer)
  • public int reduceEntriesToInt(
      long parallelismThreshold,
      ToIntFunction transformer,
      int basis,
      IntBinaryOperator reducer)
  • public long reduceEntriesToLong(
      long parallelismThreshold,
      ToLongFunction transformer,
      long basis,
      LongBinaryOperator reducer)
  • public Object reduceKeys(
     long parallelismThreshold, BiFunction reducer)
  • public Object reduceKeys(
      long parallelismThreshold,
      Function transformer,
      BiFunction reducer)
  • public double reduceKeysToDouble(
      long parallelismThreshold,
      ToDoubleFunction transformer,
      double basis,
      DoubleBinaryOperator reducer)
  • public int reduceKeysToInt(
      long parallelismThreshold,
      ToIntFunction transformer,
      int basis,
      IntBinaryOperator reducer)
  • public long reduceKeysToLong(
      long parallelismThreshold,
      ToLongFunction transformer,
      long basis,
      LongBinaryOperator reducer)
  • public double reduceToDouble(
      long parallelismThreshold,
      ToDoubleBiFunction transformer,
      double basis,
      DoubleBinaryOperator reducer)
  • public int reduceToInt(
      long parallelismThreshold,
      ToIntBiFunction transformer,
      int basis,
      IntBinaryOperator reducer)
  • public long reduceToLong(
      long parallelismThreshold,
      ToLongBiFunction transformer,
      long basis,
      LongBinaryOperator reducer)
  • public Object reduceValues(
     long parallelismThreshold, BiFunction reducer)
  • public Object reduceValues(
      long parallelismThreshold,
      Function transformer,
      BiFunction reducer)
  • public double reduceValuesToDouble(
      long parallelismThreshold,
      ToDoubleFunction transformer,
      double basis,
      DoubleBinaryOperator reducer)
  • public int reduceValuesToInt(
      long parallelismThreshold,
      ToIntFunction transformer,
      int basis,
      IntBinaryOperator reducer)
  • public long reduceValuesToLong(
      long parallelismThreshold,
      ToLongFunction transformer,
      long basis,
      LongBinaryOperator reducer)
  • public Object remove(Object key)
  • public boolean remove(Object key, Object value)
  • public Object replace(Object key, Object value)
  • public boolean replace(
     Object key, Object oldValue, Object newValue)
  • public void replaceAll(BiFunction function)
  • public Object search(
      long parallelismThreshold,
      BiFunction searchFunction)
  • public Object searchEntries(
      long parallelismThreshold,
      Function searchFunction)
  • public Object searchKeys(
      long parallelismThreshold,
      Function searchFunction)
  • public Object searchValues(
      long parallelismThreshold,
      Function searchFunction)
  • public int size()
  • public String toString()
  • public Collection values()

Fully implemented class.
 

java.util.concurrent

ThreadLocalRandom

  • public static ThreadLocalRandom current()
  • public DoubleStream doubles()
  • public DoubleStream doubles(
      double randomNumberOrigin,
      double randomNumberBound)
  • public DoubleStream doubles(long streamSize)
  • public DoubleStream doubles(
      long streamSize,
      double randomNumberOrigin,
      double randomNumberBound)
  • public IntStream ints()
  • public IntStream ints(
     int randomNumberOrigin, int randomNumberBound)
  • public IntStream ints(long streamSize)
  • public IntStream ints(
      long streamSize,
      int randomNumberOrigin,
      int randomNumberBound)
  • public LongStream longs()
  • public LongStream longs(long streamSize)
  • public LongStream longs(
     long randomNumberOrigin, long randomNumberBound)
  • public LongStream longs(
      long streamSize,
      long randomNumberOrigin,
      long randomNumberBound)
  • protected int next(int bits)
  • public boolean nextBoolean()
  • public double nextDouble()
  • public double nextDouble(double bound)
  • public double nextDouble(
     double origin, double bound)
  • public float nextFloat()
  • public double nextGaussian()
  • public int nextInt()
  • public int nextInt(int bound)
  • public int nextInt(int origin, int bound)
  • public long nextLong()
  • public long nextLong(long bound)
  • public long nextLong(long origin, long bound)
  • public void setSeed(long seed)

Fully implemented class.
 

java.util.function

BiConsumer

  • public abstract void accept(Object p0, Object p1)
  • public BiConsumer andThen(BiConsumer after)

Fully implemented class.
 

java.util.function

BiFunction

  • public BiFunction andThen(Function after)
  • public abstract Object apply(Object p0, Object p1)

Fully implemented class.
 

java.util.function

BiPredicate

  • public BiPredicate and(BiPredicate other)
  • public BiPredicate negate()
  • public BiPredicate or(BiPredicate other)
  • public abstract boolean test(Object p0, Object p1)

Fully implemented class.
 

java.util.function

BinaryOperator

  • public static BinaryOperator maxBy(
     Comparator comparator)
  • public static BinaryOperator minBy(
     Comparator comparator)

Fully implemented class.
 

java.util.function

BooleanSupplier

  • public abstract boolean getAsBoolean()

Fully implemented class.
 

java.util.function

Consumer

  • public abstract void accept(Object p0)
  • public Consumer andThen(Consumer after)

Fully implemented class.
 

java.util.function

DoubleBinaryOperator

  • public abstract double applyAsDouble(
     double p0, double p1)

Fully implemented class.
 

java.util.function

DoubleConsumer

  • public abstract void accept(double p0)
  • public DoubleConsumer andThen(DoubleConsumer after)

Fully implemented class.
 

java.util.function

DoubleFunction

  • public abstract Object apply(double p0)

Fully implemented class.
 

java.util.function

DoublePredicate

  • public DoublePredicate and(DoublePredicate other)
  • public DoublePredicate negate()
  • public DoublePredicate or(DoublePredicate other)
  • public abstract boolean test(double p0)

Fully implemented class.
 

java.util.function

DoubleSupplier

  • public abstract double getAsDouble()

Fully implemented class.
 

java.util.function

DoubleToIntFunction

  • public abstract int applyAsInt(double p0)

Fully implemented class.
 

java.util.function

DoubleToLongFunction

  • public abstract long applyAsLong(double p0)

Fully implemented class.
 

java.util.function

DoubleUnaryOperator

  • public DoubleUnaryOperator andThen(
     DoubleUnaryOperator after)
  • public abstract double applyAsDouble(double p0)
  • public DoubleUnaryOperator compose(
     DoubleUnaryOperator before)
  • public static DoubleUnaryOperator identity()

Fully implemented class.
 

java.util.function

Function

  • public Function andThen(Function after)
  • public abstract Object apply(Object p0)
  • public Function compose(Function before)
  • public static Function identity()

Fully implemented class.
 

java.util.function

IntBinaryOperator

  • public abstract int applyAsInt(int p0, int p1)

Fully implemented class.
 

java.util.function

IntConsumer

  • public abstract void accept(int p0)
  • public IntConsumer andThen(IntConsumer after)

Fully implemented class.
 

java.util.function

IntFunction

  • public abstract Object apply(int p0)

Fully implemented class.
 

java.util.function

IntPredicate

  • public IntPredicate and(IntPredicate other)
  • public IntPredicate negate()
  • public IntPredicate or(IntPredicate other)
  • public abstract boolean test(int p0)

Fully implemented class.
 

java.util.function

IntSupplier

  • public abstract int getAsInt()

Fully implemented class.
 

java.util.function

IntToDoubleFunction

  • public abstract double applyAsDouble(int p0)

Fully implemented class.
 

java.util.function

IntToLongFunction

  • public abstract long applyAsLong(int p0)

Fully implemented class.
 

java.util.function

IntUnaryOperator

  • public IntUnaryOperator andThen(
     IntUnaryOperator after)
  • public abstract int applyAsInt(int p0)
  • public IntUnaryOperator compose(
     IntUnaryOperator before)
  • public static IntUnaryOperator identity()

Fully implemented class.
 

java.util.function

LongBinaryOperator

  • public abstract long applyAsLong(long p0, long p1)

Fully implemented class.
 

java.util.function

LongConsumer

  • public abstract void accept(long p0)
  • public LongConsumer andThen(LongConsumer after)

Fully implemented class.
 

java.util.function

LongFunction

  • public abstract Object apply(long p0)

Fully implemented class.
 

java.util.function

LongPredicate

  • public LongPredicate and(LongPredicate other)
  • public LongPredicate negate()
  • public LongPredicate or(LongPredicate other)
  • public abstract boolean test(long p0)

Fully implemented class.
 

java.util.function

LongSupplier

  • public abstract long getAsLong()

Fully implemented class.
 

java.util.function

LongToDoubleFunction

  • public abstract double applyAsDouble(long p0)

Fully implemented class.
 

java.util.function

LongToIntFunction

  • public abstract int applyAsInt(long p0)

Fully implemented class.
 

java.util.function

LongUnaryOperator

  • public LongUnaryOperator andThen(
     LongUnaryOperator after)
  • public abstract long applyAsLong(long p0)
  • public LongUnaryOperator compose(
     LongUnaryOperator before)
  • public static LongUnaryOperator identity()

Fully implemented class.
 

java.util.function

ObjDoubleConsumer

  • public abstract void accept(Object p0, double p1)

Fully implemented class.
 

java.util.function

ObjIntConsumer

  • public abstract void accept(Object p0, int p1)

Fully implemented class.
 

java.util.function

ObjLongConsumer

  • public abstract void accept(Object p0, long p1)

Fully implemented class.
 

java.util.function

Predicate

  • public Predicate and(Predicate other)
  • public static Predicate isEqual(Object targetRef)
  • public Predicate negate()
  • public static Predicate not(Predicate target)
  • public Predicate or(Predicate other)
  • public abstract boolean test(Object p0)

Fully implemented class.
 

java.util.function

Supplier

  • public abstract Object get()

Fully implemented class.
 

java.util.function

ToDoubleBiFunction

  • public abstract double applyAsDouble(
     Object p0, Object p1)

Fully implemented class.
 

java.util.function

ToDoubleFunction

  • public abstract double applyAsDouble(Object p0)

Fully implemented class.
 

java.util.function

ToIntBiFunction

  • public abstract int applyAsInt(Object p0, Object p1)

Fully implemented class.
 

java.util.function

ToIntFunction

  • public abstract int applyAsInt(Object p0)

Fully implemented class.
 

java.util.function

ToLongBiFunction

  • public abstract long applyAsLong(
     Object p0, Object p1)

Fully implemented class.
 

java.util.function

ToLongFunction

  • public abstract long applyAsLong(Object p0)

Fully implemented class.
 

java.util.function

UnaryOperator

  • public static UnaryOperator identity()

Fully implemented class.
 

Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.

Last updated 2023-04-12 UTC.