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 overall investment promotion of the Artel und...
Do you feel that the Internet speed is not enough...
Affected by the residual circulation of Typhoon D...
Recently, Apple released its first quarter financ...
The four basic directions of east, west, south an...
The advantages of WeChat mini program investment ...
How to make money from Tik Tok short videos? How ...
This article mainly analyzes the "year-end s...
This is the 3722nd article of Da Yi Xiao Hu Aunt ...
[[283734]] On November 25, the Ministry of Indust...
The theory that the new coronavirus destroys the ...
How much is the quotation for Binzhou women's...
I'm Busy, Quick Reading Edition The "aci...
If you often visit Douyin, you must have been rec...
This article introduces four strategies for plann...