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
"The first bowl of noodles in the world was ...
Author: Xue Qingxin, registered dietitian Reviewe...
How much is the investment price in Chongzuo Ligh...
The advertising industry has a long history. With...
Perhaps in the near future, everyone will no long...
Creating product influence is not a one-day job. ...
Since the end of the International Consumer Elect...
After all, not everyone has the ability to manufa...
This article takes the mainstream payment system ...
The main content of the video training tutorial r...
At present, electric vehicle charging piles are m...
In recent years, the penetration rate of online e...
Do you know how to use Tik Tok, which has huge tr...
Spring is the season for all things to grow, incl...
Wuji Doudian fruit category full-case gameplay, D...