Update 2017-04-04
Jack is out of date ; Google is replacing it with what is called desugar. Now it is available with Android Studio 2.4 preview 4 and later.
The availability of the Java 8 language / library is still dependent on the level of the API device and the version of Android Studio, so make sure to double check what you can and canβt use .
To use it, you simply set the source and target language levels in Java 8.
android { ... compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } }
Please note: if you are already using retrolambda or jack, you need to disable them to use desugar. You will find more information on how to use it here .
I have not tried this myself yet, since I prefer IntelliJ IDEA, and quick research on how to use it with IDEA has not been fruitful. I will update this answer again when I figure out how to use it in IDEA.
Old answer
Some Java 8 language features are available using the Jack compiler.
to enable jack, edit your build.gradle
so
android { ... defaultConfig { ... jackOptions { enabled true } } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } }
More information can be found here.
However, I would like to add that so far I have had pretty poor experience with jack, especially when debugging. I would recommend using streamsupport and retrolambda instead until jack jill is released.
Zharf source share