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.
Java 8 has been supported natively since Android SDK 26. If you wish to use Java 8 language features and your minimal SDK version is lower than 26, . class files produced by the javac compiler need to be converted to bytecode that is supported by these SDK versions.
Class libraryJava 8 source code that works in latest version of Android, can be made to work in older versions of Android.
Android SDK tools are not yet compatible with Java 11 and need Java 8 (1.8) to run correctly. The Bitrise stacks provide both Java 8 and Java 11, with Java 8 being active by default. If you need a Java 11 runtime for your project to compile, you can switch to Java 11 only before it's needed by the next Step.
A copy of the latest OpenJDK comes bundled with Android Studio 2.2 and higher, and this is the JDK version we recommend you use for your Android projects.
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.html
The 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.
Android supports all Java 7 language features and a subset of Java 8 language features that vary by platform version.
To check which features of java 8 are supported
Use Java 8 language features
We've decided to add support for Java 8 language features directly into the current javac and dx set of tools, and deprecate the Jack toolchain. With this new direction, existing tools and plugins dependent on the Java class file format should continue to work. Moving forward, Java 8 language features will be natively supported by the Android build system. We're aiming to launch this as part of Android Studio in the coming weeks, and we wanted to share this decision early with you.
Future of Java 8 Language Feature Support on Android
For old developers who prefer Eclipse, google stops support Eclipse Android Developer tools
if you installed Java 8 JDK, then give it a try, if any problems appears try to set the compiler as 1.6 in Eclipse from window menu → Preferences → Java → Compiler. Java 7 will works too:
Java 7 or higher is required if you are targeting Android 5.0 and higher.
install multiple JDK and try.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With