I recently installed jdk 1.8 u92 after Android Studio said it is needed for api24 builds. However, I've run into this issue now.
I looked at some other solutions and uninstalled jdk 1.7, added environment variables for JDK_HOME, JAVA_HOME, and JAVA8_HOME. The problem still persists.
Every time I try to build the app, gradle sync fails and Android studio asks me to Choose a valid JDK directory. I then go to Project Structure => JDK Location and update it to the 1.8 folder. Trying to build again gives the same error and when I check the Project Structure, the path is set back to the old JDK 1.7 automatically.
Is there any fix for this issue?
Figured it out after looking at a few files inside the Android studio settings directory.
If you've been upgrading your Android Studio and importing settings from previous installations, this might happen (it might also happen with a fresh installation).
Solution:
This fixed the issue for me. The newly created jdk.table.xml will have updated java8 values (which it most probably fetches from the JDK_HOME environment variable).