Java – Android and lambda
I need to integrate some code with the widespread use of Java lambda functions
The problem is that using lambda requires 1.8 JDK compatibility, but if it is set to this, I will receive the following message:
Android requires compiler compliance level 5.0 or 6.0. Found '1.8' instead.
How do they get along?
Editor: This is not a repetition of the suggested question, because I'm asking ADT eclipse, and since the last update on this question, Android does support Java 8, so it's not just that this is not a repetition, but this question is now (1.5 years after the last update) outdated
Solution
As @dhke said, Java 8 is not yet supported on Android
Using java 8, build for Java 6 / 7
But you can still use JDK 8 to develop Android applications You only need to set the source compatibility to 6 or 7, depending on your minsdkversion Therefore, you will lose any new features introduced in Java 8, such as lambda
Lamda's backstage
Because you widely use lambda, retroambda may be your choice It provides the suffix of lambda for the previous Java 8 version It is supported by Maven / gradle / command line plug-ins
Other rear ports
If you need other Java 8 functions, AFAIK and threeten ABP can provide background support for Java 8 date time API