Philipp
Philipp

Reputation: 11833

Source/Target compatibility list in Android Studio

I am in the process of updating my Android studio, Android build tools, gradle version and JDK version. Trying to switch to JDK 1.8 I am wondering why the list in the Android Studio dropdowns for "Target compatibility" and "Source compatibilty" (in the module settings) only contain the values 1.6 and 1.7. Does this mean I forgot to install/update anything or forgot to change some path?

I know I can enter 1.8 manually, but the question is whether the missing 1.8 value means my setup might be incorrect?

Upvotes: 2

Views: 1154

Answers (1)

Eugen Pechanec
Eugen Pechanec

Reputation: 38243

Source and target compatibility has nothing to do with installed JDK. Your source code will still be compiled to Java 6/7/8 byte code which is used by Android. (Someone in comments, please point out technical inaccuracies, thanks.)

Source and target compatibility affects language constructs you can use in source code. E.g.

  • when targeting Java 6 you can't use the diamond operator,
  • when targeting Java 7 you can't use lambdas, etc.

Android Studio 3.0 and accompanying build plugin for Gradle (currently in development) will support Java 8 syntax out-of-the-box. Until then you could use retrolambda. Or straight up switch to Kotlin.

And of course then you'll need at least JDK 8 to target Java 8.

Upvotes: 3

Related Questions