Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle in Android Studio giving error Project sync failed

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 issue

I am getting following error in messages

Error:The newly created daemon process has a different context than expected.
Java home is different.
Expecting: 'C:\Program Files\Java\jdk1.7.0_40' but was: 'C:\Program Files\Java\jdk1.7.0_40\jre'.
Please configure the JDK to match the expected one.
<a href="open.project.structure">Open JDK Settings</a>

All i understood is gradle is using JRE and Android Studio is using JDK and due to that two JAVA_HOME's are different and giving errors.

I tried downloading gradle 2.3 and changed gradle path in android studio to this file,still same problem.

like image 401
smali Avatar asked Jun 04 '15 11:06

smali


2 Answers

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.

like image 153
James Avatar answered Oct 18 '22 22:10

James


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

like image 27
Sandeep Singh Avatar answered Oct 18 '22 23:10

Sandeep Singh