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 main factors affecting the price of mini prog...
Many parents ask whether the Wenchang Tower reall...
On February 15, the official website of New Weekl...
I have heard many of my friends and colleagues ta...
On July 20, Mercedes-Benz plans to launch its firs...
For many people, coffee It has a refreshing effec...
Introduction to the video resource of the 2021 &q...
In the past two years, many industries have faced...
1. Introduction Functional Responsive Programming...
1. What is a short video script? A short video sc...
Ear piercing has been a common thing since ancien...
A strong physique and abundant vitality are the &...
With the disappearance of the Internet traffic di...
This article will explain from the thinking level...