Using Java 8 in android studio

I am using android studio and I want to use a lambda expression that is only available from java 8, and when I try to use it, I get:

Lambda expression are not supported at this language level. 

So how can I change this on AndroidStudio?

+7
android android-studio java-8
source share
2 answers

So how can I change this on AndroidStudio?

You can not. Android supports up to java 7. If you want to use AS only for Lambda, you can use gradle-retrolamba or retrolambda , which is back-port retrolambda on java 6/7

+7
source share

Android supports Java 6 before KitKat (4.4) with a little syntactic sugar (like a diamond operator) and Java 7 from there (Lollipop and Marshmallow atm). Lambdas and other Java 8 materials are only available as plugins (e.g. gradle-retrolambda or the original retrolambda ). They will probably be included in the API at some point in time (for example, Java 7 and KitKat), but this is unlikely to happen very soon.

+2
source share

All Articles