I am new to Android Studio.I installed Android Studio-1.2.1.1 and i have jdk1.7.0_40 installed.I am facing problem with gradle build. For reference you can check gradle issu
This is 2019. For anyone experiencing this issue... The first thing is to make sure that you correctly set your environment variables as per this instruction: https://www.mkyong.com/java/how-to-set-java_home-on-windows-10/
Which means you should be able to type javac -version and java -version and get the version number inside your Home directory.
Once you can confirm this, then go to the Project Structure inside, the SDK Location > JDK Location select Use JAVA_HOME environment variable.
This was what I did and it worked.