Android Studio - supplied javaHome is not a valid folder

The problem was my project's JDK location. From the Android Studio Project tool window, I right clicked on the root directory, selected 'module settings', and set the JDK location. Everything's fine now.


I don't know why or how this problem occurred but this answer got me over the hump. On macOS rm -rf ~/.gradle to wipe out the cache then restart Android Studio. I tried everything else up to and including reinstalling the JDK and Android Studio. Wiping out the .gradle directory is the only thing that worked.


Try to delete all .iml files and .idea, and re-import the project from Gradle. Worked for me (provided you have everything else set up).

This error happens when you switch from Intellij to Android Studio, or the other way around, and load the same project. Looks like their project model is not compatible.