Similar to:
- Intellij 14 the supplied javaHome seems to be invalid
- Android Studio - supplied javaHome is not a valid folder
However, I am trying to use
This can be fixed by setting the Project SDK in Module settings to a JDK (as opposed to the Module SDK (which shall be Android SDK)
I tried this and it worked for me flawlessly. go To SETTING-->SEARCH 'Gradle'---> and choose Gradle JVM and choose the option Use JAVA_HOME C:\ProgramFiles\Java\JDK\1.8 hope this helps someone.
in IntelliJ 2018.1, I ran into this problem because my project SDK was set to Kotlin instead of a JDK. So, despite having a Kotlin project, it would only build if the SDK is a JDK.
Upgrading IntelliJ UE from v14.1.1 to 14.1.7 worked for me.
I've solved this issue by putting gradle.properties file in the same dir as build.gradle with exact path to my JDK:
org.gradle.java.home = C:/Dev/JDK
Actually it is not a correct solution, probably it should be fixed in IDE, I see in IDEA logs something like (when I executing gradle task of already imported project):
INFO - s.plugins.gradle.GradleManager - Instructing gradle to use java from C:/Dev/JDK
But when I going to import gradle module to the project I don't see such kind of message, probably IDEA passes link to bundled JRE which is actually not a JDK.
I encountered the same problem for quite a while and no matter how many forums I looked at it just did not solve the problem.
Long story short, I found out my antivirus quarantined the java.exe file. So I advise you to open your antivirus and restore the Java.exe file then relaunch android studios.