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.
A subset of Java 8 is supported now on Android Studio. Just make the Source and Target Compatibility adjustments from the window below:
File --> Project Structure
More information is given in the below link.
https://developer.android.com/studio/write/java8-support.html
Add this config build.gradle and sync gradle:
UPDATE 2017/11/04 - Android Studio 3.0 now has native support for Java 8.
gradle-retrolambda
is now no longer needed. See https://developer.android.com/studio/write/java8-support.htmlThe above link also includes migration instructions if you are using
gradle-retrolambda
. Original answer below:Android does not support Java 8. It only supports up to Java 7 (if you have kitkat) and still it doesn't have invokedynamic, only the new syntax sugar.
If you want to use lambdas, one of the major features of Java 8 in Android, you can use gradle-retrolamba. It's a gradle build dependency that integrates retrolambda, a tool that converts Java 8 bytecode back to Java 6/7. Basically, if you set the compiler in Android Studio to compile Java 8 bytecode, thus allowing lambdas, it'll convert it back to Java 6/7 bytecode which then in turn gets converted to dalvik bytecode. It's a hack for if you want to try out some JDK 8 features in Android in lieu of official support.