Language Subset

Android uses a standard Java compiler to compile your source code into regular bytecodes and then translates those bytecodes into instructions to execute. Therefore, nearly the entire Java language is supported, not just a small subset. By using the stock compiler and bytecodes, you often don’t even need to have the source code for libraries that you want to use in your applications.

Language Level

Android Studio supports code compatible with Java Standard Edition 6 or earlier, with optional additions from Java 7. At present, none of the Java 8 features are available.

To enable Java 7 language features, you need to add these lines to your gradle build file:

 
compileOptions {
 
sourceCompatibility JavaVersion.VERSION_1_7
 
targetCompatibility ...

Get Hello, Android, 4th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.