Since Android N, some of the Java 8 language features are finally supported thanks to the new Jack & Jill compiler toolchain. This however comes with several limitations like for example an inability to use the new compiler along with the data binding support library or limited annotations support. But that doesn’t mean that you should give up on advanced language features of Java 8 at all. In this post, I’ll introduce you to a way how to enable Java 8 features in Android by using four libraries back-porting Java 8 functionality to lower Java versions.
In the previous post, lambda expressions in Java 8 have been introduced. In this post I will describe how to enable and use Java 8 language features including lambda expressions in Android development.
Until recently, only Java 7 was officially supported when developing for Android. However, this changes with the release of Android N (Nougat, API version 24) and its official support for Java 8. Before Android N was released however, it was also possible to use an external library called retrolambda which allows to bring lambda expressions support to Java 7 and lower.
Java 8 brought many new features known up until now mainly from functional programming languages. Among the most interesting ones, there are lambda expressions, default methods, stream API, etc. In this post, let me introduce you to the first of listed — lambda expressions.