lxgr lxgr - 2 months ago 19x
Java Question

Java 8 Stream API in Android N

According to Google's introduction, starting with Android N, the Android API is supposed to support Java streams.

However, using the Android N preview SDK, I am unable to use any of the Stream APIs in my project (which is configured with Android N as minimum, target and build SDK version).


package seems to be missing, as are the
methods of all collection implementations I've tried.

Are the necessary classes not yet included in the current preview release of the SDK?


It's not yet in the current preview, but it has already been merged into the AOSP Git master. See here https://android.googlesource.com/platform/libcore/+/916b0af2ccdd1bdfc0283b1096b291c40997d05f


Just to avoid possible confusion: in March 2016, when this question has been asked by the OP, Android N developer preview-1 was the only publicly available build of what is now known as Android 7.0 "Nougat".

The preview-1 build did in fact not include the Java 8 Stream API, but it was added shortly after (one month later) in the developer preview-2 build.

So, Android 7.0 API level 24 does support the Java 8 Stream API now.