问题
Does IntelliJ Android Studio last update (From 30/Jan/2016) supports Java 8?
I used a lambda expression
mButton.setOnClickListener((View v) -> {
// do something here
});
then Android Studio tells me I have an error and when I resolve the problem (Alt+spacebar) I choose the Change to Java 8 (or something like that) and it works the lambda but the libraries from Android seems to be unsupported it marks all in red.
Any options for supporting Java 8 in Android Studio?
Note: I'm using the last API Level
回答1:
No, Java 8 isn't supported. What you can do instead to write Lambdas and method references is to include retrolambda dependency to your project. Same with streams, here is a backport library. Alternatively, consider using kotlin.
回答2:
Android is using the retired Apache Harmony as its Java implementation and I believe Harmony is on Java 6, so no, Java 8 is not supported.
Java 8 will be supported in Android N though as it will use OpenJDK instead of Harmony.
来源:https://stackoverflow.com/questions/35106196/does-android-sdk-with-api-23-marshmallow-supports-java-8