Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error "could not fetch model of type 'BasicIdeaProject' using Gradle distribution" in Windows?

When I try to open a project by clicking at my build.gradle, I see this message:

Could not fetch model of type 'BasicIdeaProject' using Gradle distribution 
'http://services.gradle.org/distributions/gradle-1.4-bin.zip'. The supplied 
javaHome seems to be invalid. I cannot find the java executable. Tried location: 
C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 12.1\jre\bin\java.exe

I think this happens because IntelliJ searches jre at the wrong folder, because in my IntelliJ directory, I have this sctructure:

C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 12.1\jre\jre\bin\java.exe

Of course I can move the ...\jre\jre\bin folder to the ...\jre, but if I do this, I see this another message, when try openning the project:

Error: could not open `C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 12.1\jre\lib\i386\jvm.cfg'

That is, it can't find the lib folder. Again, I can copy the ...\jre\jre\lib folder to the ...\jre folder, but already there is a folder called lib at the ...\jre folder, that contains only the file tools.jar.

So, how can I do IntelliJ to search at right folder?

Update:

This is my JAVA_HOME:

C:\Program Files (x86)\Java\jre7
like image 683
androidevil Avatar asked Jun 02 '13 17:06

androidevil


2 Answers

From the "Ideaj Quick Start" select "Configure"->"Project Defaults"->"Project Structure"

From there in the popup that follows, select "SDKs" -> (under Platform Setting on the left) and make sure that the locations of your 1.6 and 1.7 are correct (I was off by an update apparently)

like image 72
Terrance Avatar answered Sep 20 '22 11:09

Terrance


I faced the same error and checked project structure several times. Everything was just fine. I started facing this error after upgrade from intellij 14.0 to 14.1.1. The solution worked for me is following, pasting it here so that other can be benefited from it too.

Go into the jre file and if you find another jre file inside it. Move the files in that other jre to the first jre file and everything should work just fine. When move just don't delete anyfile for example the lib folder is also persent inside and outside of JREs; outside one has tools.jar that probably might be needed. So complete copy without replace should work just fine.

I feel it is bug in intellj when you upgrade the version it messes up with configuration.

I hope this helps others.

like image 25
Mohammad Adnan Avatar answered Sep 21 '22 11:09

Mohammad Adnan