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.functionpackage 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.timeandjava.util.streampackages in addition to everything in the minimal version. - The nio version includes the
java.niopackage 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_nio: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 |
|
Additional methods on existing class. |
java.io |
|
Additional methods on existing class. |
java.io |
|
Additional methods on existing class. |
java.io |
|
Additional methods on existing class. |
java.io |
|
Fully implemented class. |
java.lang |
|
Additional methods on existing class. |
java.lang |
|
Additional methods on existing class. |
java.net |
|
Fully implemented class. |
java.net |
|
Fully implemented class. |
java.nio.channelsSee customizations AsynchronousChannel |
|
Fully implemented class. |
java.nio.channelsSee customizations AsynchronousFileChannel |
|
Fully implemented class. |
java.nio.channelsSee customizations CompletionHandler |
|
Fully implemented class. |
java.nio.channelsSee customizations FileChannel |
|
Additional methods on existing class. |
java.nio.channelsSee customizations SeekableByteChannel |
|
Fully implemented class. |
java.nio.charsetSee customizations StandardCharsets |
|