4

I installed the latest Java 8 on my Mac and the latest Android Studio. In Android Studio I cannot find java.util.function. This leads me to believe that it's not using Java 8. I have search for a log time and the only Java I have on my Mac is Java 8. I also checked the Project Structure and it's pointing to Java 8. I reinstalled Android Studio, created a new project, and I still cannot import java.util.function. Does Android studio really work with Java 8? Any suggestions on how to get access to java.util.function?

Jeff Zacharias
  • 381
  • 3
  • 12
  • Thanks to everyone who answered. It was not clear to me. I'm new to Android with lots of iOS experience. I was trying to create the equivalent of an iOS Swift closure. After much reading it seemed like Java 8 Lambda/Function would be perfect. I guess I'll have to figure this our for Java 6 or 7. – Jeff Zacharias May 25 '15 at 14:20

2 Answers2

2

In Android Studio I cannot find java.util.function

Android does not yet support Java 8, so this is no surprise. As of KitKat, Android targets Java 1.7.

This leads me to believe that it's not using Java 8

You are right.

Any suggestions on how to get access to java.util.function?

This is not really possible. If it was pure Java code you could have a chance of retrofitting the code in an Android compatible way. But java.util.function (and @FunctionalInterface) is part of the language spec so it doesn't really make sense to even try.

Related discussions:

Community
  • 1
  • 1
aioobe
  • 413,195
  • 112
  • 811
  • 826
2

Does Android studio really work with Java 8?

Android doesn't support Java 8. Some of the Java 1.7 features are supported since kitkat

Blackbelt
  • 156,034
  • 29
  • 297
  • 305