Gradle in Android Studio giving error Project sync failed
Replace this
C:\Program Files\Java\jdk1.7.0_40\jre
with
C:\Program Files\Java\jdk1.7.0_40
inside your JAVA_HOME
variable
This is a very late answer but I see that a common suggestion is to remove all other jdk's and this is not always the best idea. You might need older jdk's for different projects. You can go into the gradle.properties file for the project and enter the following line (varied based on your version):
org.gradle.java.home=C:/Java/jdk1.8.0_111
If you are using a different jdk just point to a different directory.