Java 8 Stream API in Android N

时光毁灭记忆、已成空白 提交于 2019-12-10 01:38:20

问题


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).

The java.util.stream package seems to be missing, as are the stream() methods of all collection implementations I've tried.

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


回答1:


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

EDIT:

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.



来源:https://stackoverflow.com/questions/36112086/java-8-stream-api-in-android-n

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!