Even though I manually configured JDK project structure file/Project structure it still shows this error FAILURE: Build failed with an exception.
`What went wrong:
This happens when JDK and JRE have different versions installed on your system. Update the JDK with the matching version of JRE. Also verify that System variable path has bin value from same JDK version.
My issue was two-fold:
Note: I am using Fedora Linux.
To resolve the first issue, I followed these instructions
To resolve the second, I merely added the following line to my ~/.bashrc
file:
export JAVA_HOME=/usr/lib/jvm/java/
I had to restart my IDE and terminals to ensure the change to the ~/.bashrc
took affect.
The problem is your gradle build is not finding the JAVA_HOME path or JDK folder. So, you could declare the path in gradle.properties like org.gradle.java.home=C:\Program Files\Java\[or yours jdk folder name].
Use this guide for using gradle.properties.
Or (and I prefer this solution) include JAVA_HOME path in systmem variables and restart CMD.
At last, here I found the solution.
I added jdk path org.gradle.java.home=C:\\Program Files\\Java\\jdk1.8.0_144
to gradle.properties
file and did a rebuild. It works now.
This can occur if your path is too long as well. I solved this by moving my java install to
C:\Java\jdk1.8.0_211
My error was solved by uninstalling all java updates and java from control panel and reinstalling JDK