Searching the web, it is not clear if Java 8 is supported for Android development or not.
Before I download/setup Java 8, can some one point me at any "official" documentation that says Java 8 is or is not supported for Android development.
Searching the web, it is not clear if Java 8 is supported for Android development or not.
Before I download/setup Java 8, can some one point me at any "official" documentation that says Java 8 is or is not supported for Android development.
Follow this link for new updates. Use Java 8 language features
Old Answer
As of Android N preview release Android support limited features of Java 8 see Java 8 Language Features
Supported Java 8 Language Features and APIs
Default and static interface methods
Lambda expressions (also available on API level 23 and lower)
Repeatable annotations
Method References (also available on API level 23 and lower)
There are some additional Java 8 features which Android support, you can see complete detail from Java 8 Language Features
Update
Update 2
Now Android studio 3.0 stable release support Java 8 libraries and Java 8 language features (without the Jack compiler).
Latest news:
Google announce that with Android N and Android Studio 2.1+, platform will support Java 8. Also stable version of studio 2.1 was released.
At last we can use lambda expressions. No more list filter in for loop. Horeeey.
Android Studio 3.0 started to provide built-in support for some of Java 8 language features, which are:
Also starting from API level 24 the following Java 8 API are available:
java.util.stream
java.util.function
java.lang.FunctionalInterface
java.lang.annotation.Repeatable
java.lang.reflect.AnnotatedElement.getAnnotationsByType(Class)
java.lang.reflect.Method.isDefault()
Besides that, the
try-with-resources
support was extended to all Android API levels.More Java 8 features are promised to be added in the future.
For more details visit:
https://developer.android.com/studio/write/java8-support.html
When I asked this question almost 2 years ago the answer really was “officially” no, but as pointed out by ekcr1's answer you can get one of the most highly anticipated features (lambdas) to work if you use retrolamba. At the time I was still using eclipse, as Android Studio was in “preview” mode, so I never did pursue this path.
Today, I think the “official” answer is still no, and while retrolamba still seems like a good way to go, there is another option for those willing to go down a somewhat “unofficial” route can take, namely Kotlin.
Today Kotlin reached 1.0.0. For those not familiar with Kotlin, more info can be found at their website found here:
https://kotlinlang.org
or watch this utube video of a talk given by Jake Wharton
https://www.youtube.com/watch?v=A2LukgT2mKc
We Can Use Java 8 using:
In build.gradle (Project: myProject) add following
In build.gradle (Module: myModule) add following
I asked this question over 3 years ago and obviously the answers have changed over the years. As many above have already answered, as of sometime back, the answer became Yes. I have never updated the accepted answer because it was the correct answer at the time. (I am not sure what the Stack Overflow policy is on that)
I just wanted to add another answer for those who still search for this topic. As of 5/17/2017 Google also announced that Kotlin is also an official language for Android development.
I have not found an official press release, but I did watch some of the Google I/O videos where it was announced. Here is a link to a blog post by the Kotlin team on the announcement.