
Support for partial Java API desugaring is available from the Android Gradle (such as .*) available for use on older Android releases. Plugin 3.0.0 and higher and doesn't make any additional classes and APIs Java 8+ language features desugaring on the Android Gradle If that doesn't work, consider using an alternative library that That library with minSdkVersion 25 or lower, Methods even when they're included in a library dependency. In some cases, your module might not be using the invoke or invokeExact Otherwise, you receive theįollowing error: Dex: Error converting bytecode to dex:Ĭause: signature-polymorphic method called without -min-sdk-version >= 26 You need to specify minSdkVersion 26 or higher. If your source code or one of your module dependencies uses one of these methods, Try-with-resources to all Android API levels. Versions 3.0.0 and higher extend support for In addition to these Java 8 language features, Android Gradle plugin In API level 24 and below, but not ElementType.TYPE_USE or Type annotation information is only available at compile time, The following languageįeatures are available on any API level: Java 8 language featureĪndroid doesn't support the serialization of Plugin doesn't support all Java 8 language features. When building your app using the Android Gradle plugin 3.0.0 and higher, the TargetCompatibility = JavaVersion.VERSION_1_8 SourceCompatibility = JavaVersion.VERSION_1_8 TargetCompatibility JavaVersion.VERSION_1_8 SourceCompatibility JavaVersion.VERSION_1_8 language features (either in its source code or Configure only for each module that uses Java 8

Update the module's adle or file as shown below:

Language features (either in its source code or through dependencies), To start using supported Java 8 language features: Java 8 language feature support (Android Gradle Plugin 3.0.0+) Bytecode level 6 has a faster build and fewerįeatures, whereas bytecode level 7 has a balance of features and build speed,Īnd bytecode 8 is more feature rich with slower builds. Note: Your choice of bytecode level is a balance between functionality and build

Java 8 language feature support using desugar

Of class files into DEX code, as shown in figure 1. Implements the new language features by performingīytecode transformations, called desugar, as part of the D8/R8 compilation Language features and third-party libraries that use them. The Android Gradle plugin provides built-in support for using certain Java 8 You can keep your project's source and targetĬompatibility values set to Java 7, but you still need to compile using JDK 8. Note: When developing apps for Android, using Java 8
