How to add Java 9 to Android Studio?

Varun A M picture Varun A M · Oct 23, 2019 · Viewed 7.9k times · Source

I am using Robolectric library and the latest version of it v4.3.1 requires Java 9 to run. I am trying to point JRE on edit configurations but I am not finding Java 9 in the drop-down even though I have already installed it. It would be really helpful if somebody can please explain!

enter image description here

Please check Java 9 installed.

enter image description here

Answer

Eugen Martynov picture Eugen Martynov · Oct 24, 2019

The only workaround to run Robolectric test in the Android Studio is to change JRE for the test task.

Select IDE menu Run -> Edit Configuration and then change the option from the picture to the location of JDK9:

screenshot