1

I recently started development with Android Studio 1.1.0 (bundle 135.1740770 for Windows) having JDK version "1.8.0_40" installed (64 Bit).

So far everything works fine, except I cannot import classes added with Java 8. I recognized it when trying to import java.util.Optional, but it's the same with e.g. java.util.stream.

May it be the case that my project somehow only uses a Java 7 subset of my JDK's standard library? And is it possible (recommended) to change that? I looked for a java version param in properties files, manifest and IDE settings. Didn't find anything like that.. anyone experienced something like that?

Btw. following the first comment in Is it possible to use Java 8 for Android development? it should be possible basically, but it seems to only cover Eclipse..

Community
  • 1
  • 1

1 Answers1

3

If you read further down in your linked comments, you will find the solution:

You may use JDK 6 or above for Android development. However, the compilation supports Java version 6 (and 7 in case of KitKat).

So yes, you may use JDK 8 for development, but you need to set the language level to JDK 6 or JDK 7. You cannot use any features that were added to JDK 8. To set the language level in Android Studio, go to:

File > Project Structure > Project > Select Project language level

Darek Kay
  • 15,827
  • 7
  • 64
  • 61
  • 1
    oh how bad, Java 8 stuff looked quite promising language-wise. you're totally right. searching for that shows it seems to be not even in reach.. http://www.quora.com/When-will-Android-support-Java-8 – Stefan Gränitz Mar 12 '15 at 21:50