News

Android Studio 2.4 Preview 6 Fixes Java 8 Support

Google is continuing to implement support for Java 8 in its Android mobile OS, last week issuing Android Studio 2.4 Preview 6, which fixes numerous bugs associated with the company's new way of working with the latest edition of its default programming language.

As we reported last month, Google has ended its experiment to implement Java 8 support with the Jack (Java Android Compiler Kit) toolchain. Instead, the company said it's providing improved support for Java 8 language features by "desugaring" them in the default build system.

That new way of supporting Java 8 was introduced in Preview 4 of the upcoming Android Studio 2.4 revamp and is getting smoothed out in the preview process.

"Java 8 language features are now supported by the Android build system in the javac/dx compilation path," product manager James Lau said in a blog post last week. "Android Studio's Gradle plugin now desugars Java 8 class files to Java 7-compatible class files, so you can use lambdas, method references and other features of Java 8.

"For those of you who tried the Jack compiler, we now support the same set of Java 8 language features but with faster build speed. You can use Java 8 language features together with tools that rely on bytecode, including Instant Run. Using libraries written with Java 8 is also supported."

Java 8 Language Feature Support Using Desugar Bytecode Transformations
[Click on image for larger view.] Java 8 Language Feature Support Using Desugar Bytecode Transformations (source: Google)

Lau said the latest preview fixes a lot of bugs associated with the new way of supporting Java 8, and he offered thanks to Android community developers who filed bug reports.

According to Google's "Use Java 8 language features" guidance, Android Studio doesn't support all Java 8 language features, but such support is being added with new versions of the IDE.

In addition to the aforementioned lambda and method reference support, some other notable Java 8 features that Android Studio currently supports (with variations according to targeted SDK versions) include Lambda type annotations, default and static interface methods and repeating annotations.

"The default toolchain implements the new language features by performing bytecode transformations, called desugar, on the output of the javac compiler," Android Studio documentation says. "Jack is no longer required, and you should first disable Jack to use the improved Java 8 support built into the default toolchain."

About the Author

David Ramel is an editor and writer for Converge360.