12

I am running Android Studio 3.5 Beta 5. I have been following a rabbit hole starting with trying to run unit tests with Robolectric against Android SDK 29. I saw an error that required running with Java 9. When I went to install JDK 9, it directed me to 10, then 11, then 12!

I downloaded JDK 12 and now I would like to configure Android Studio's JDK location to be 12. However, when I attempt to do that, I get the following warning message: "Please choose a valid JDK 8 directory". See screenshots below.

Is there another setting I have to change to get this dialog to allow me to choose a JDK greater than 8? Or is it just not possible?

project structure dialog

warning message

B W
  • 582
  • 1
  • 6
  • 19

2 Answers2

4

Oracle Java and Android Java aren't the same - they don't even use the same virtual machine.

So Sadly u can not use it now, until Android support it.

Eslam Ahmad
  • 509
  • 4
  • 6
3

you actually can compile Android apps using a higher JDK version while targeting Java 8 within your apps. it seems that this was supported in Android Studio versions before 3.5 beta 3, and according to the issue tracker, they plan on fixing this.

in the meanwhile, you can compile with higher JDK versions on the command line with Gradle without any issues.

ahmedre
  • 1,614
  • 1
  • 13
  • 17