The Android team released Android N Preview with a lot of improvements, including Java 8 support provided by the Jack compiler. In this post, we'll take a look at what it means for Android developers and how to try out the new language features. OverviewIn this article, it does not make much sense to introduce the new features of Oracle Java 8 - a lot of information is already available on the Internet. On the other hand, the official Java 8 announcement for Android leaves a lot of open questions for developers, and it feels like not all native Java 8 features are available. The more detailed technical announcement confirms this. We can categorize these language features according to their availability in Android N as follows: Android Gingebread (API 9) and above:
Android N and above:
So the correlation between Java 8 features and the used minSdkVersion has to be carefully chosen by the developer. We must also note that language backward compatibility is provided by the Jack compiler. Conceptually, the Jack compiler combines the functionality of javac, ProGuard, and dex into a single transformation step. This means that no intermediate Java bytecode is available, and tools like JaCoCo and Mockito will not work, as does DexGuard (the enterprise version of ProGuard). Let's hope that this is just an early preview version and that these issues will be fixed in the future. Lambda expressions and related functional APIs - this is something every Android developer will love. This kind of feature will be extremely useful to increase the readability of the code - it replaces anonymous inner classes that provide event listeners. Previously, it could only be achieved through additional tools or by Android Studio editor to fold the code. Default and static interface methods can help us reduce the number of additional utility classes, but are clearly not the most needed features. There are some other new features that I would like to talk about in more detail, so they are beyond the scope of this article. The most interesting thing for me — Java 8 Streams — is not available in the current preview. We can see that it was actually just merged into AOSP sources, so expect to see it in the next N Preview or Beta release. If you really can’t wait to explore — try to use Lightweight-Stream-API, which is currently open source and backwards compatible. SummarizeIn this post, we looked at the use cases for Java 8 and its current implementation in the Android N Preview SDK. We also looked at the current limitations of the Jack compiler and how they might be fixed before the latest release. |
<<: Android 8.1 is coming: new features make users applaud
First of all, congratulations to the students who...
After the mini program won the recognition of var...
Some time ago, Apple released iOS13.4.1, and the ...
Dreaming is a confusing, hazy experience that is ...
Nowadays, if you want to build a brand, you can...
Many operators now have a feeling: the number of ...
The word atom was invented by the ancient Greeks,...
It is easy to create an APP, with a R&D team ...
Author: Jin Xin, Director of the Shouyang Myopia,...
Not long ago, the iOS version of WeChat was updat...
Of course, this is not the most terrible thing. T...
Image source: Tuchong Creative Why does fortune-t...
"Nodules", "polyps", "cy...
ESA's Solar Orbiter will pass through the tai...
Jianshu 's positioning was very clear when it...