1

I am trying to get gradle project support in my latest eclipse. I installed the official gradle plugin from eclipse marketplace. I downloaded a couple of gradle based projects randomly from github (just to test) and whenever I import any of them, they start downloading a different gradle zip for each project. gradle-2.2.1-all.zip and gradle-2.9-all.zip and others.

and I end up getting this error when it's downloaded, it never lets me import the project:

Synchronize Gradle builds with workspace failed due to an error in the referenced Gradle build. Could not fetch model of type 'EclipseProject' using Gradle distribution 'https://services.gradle.org/distributions/gradle-2.9-all.zip'. A problem occurred configuring project ':cSploit'. SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable. org.gradle.tooling.BuildException: Could not fetch model of type 'EclipseProject' using Gradle distribution 'https://services.gradle.org/distributions/gradle-2.9-all.zip'.

so the questions are:

1) do I need a different gradle zip for each project?

2) do I need to download the same zip again if I import the same project again after switching to some other project?

3) can't I just download the latest gradle zip which is supported by all projects?

4) how do I fix this error?

guipivoto
  • 18,327
  • 9
  • 60
  • 75
abbie
  • 345
  • 5
  • 22
  • 1
    Possible duplicate of [Gradle, Android and the ANDROID\_HOME SDK location](http://stackoverflow.com/questions/19794200/gradle-android-and-the-android-home-sdk-location) – OneCricketeer Jun 10 '16 at 03:10

1 Answers1

0

Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.

All versions of Gradle are going to give you that error. The reason those github projects do not contain that file is because it is specific to your computer, therefore isn't committed to source control.

To do so, create local.properties in the root of your project and add this (of course updating the path)

sdk.dir=/path/to/android/sdk

If you would like to use consistent versions of Gradle, edit the distributionUrl value in gradle-wrapper.properties

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
  • You should preferably using the latest Gradle distribution. You don't need to download individual/older versions for various projects, it should be downloaded to your user's home folder – OneCricketeer Jun 10 '16 at 03:22
  • Refer to the duplicate question I flagged above – OneCricketeer Jun 10 '16 at 03:25
  • Depends on your computer, but I think on Linux or Mac, there is a `.gradle` or `.m2` hidden folder in your User home directory where it is downloaded – OneCricketeer Jun 10 '16 at 03:29
  • Of download it manually. Eclipse does not include it. http://gradle.org/gradle-download/ – OneCricketeer Jun 10 '16 at 03:30
  • Look at the `gradle-wrapper.properties` file. I think it's all. As I said, though, Gradle will download the wrapper on its own. You shouldn't need to do it yourself. Plus you'll need to additionally change some settings to point Gradle at the file you download – OneCricketeer Jun 10 '16 at 03:42
  • There should be a wrapper folder. At least that is the standard Android Studio project layout. Alternatively, Android Studio is a great IDE – OneCricketeer Jun 10 '16 at 03:48
  • That's the wrong file. Please carefully compare the names I have mentioned – OneCricketeer Jun 10 '16 at 03:50
  • Not sure what to tell you, then. The folder that you use should be the folder that contains `build-tools` and `platform-tools` – OneCricketeer Jun 10 '16 at 03:57
  • I've had problems with the ANDROID_HOME variable not getting read. I think you need `D:\\sdk` because that backslash needs escaped – OneCricketeer Jun 10 '16 at 04:01
  • tried `D:\\sdk` already, but some other path is still overriding my path – abbie Jun 10 '16 at 04:03
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/114301/discussion-between-cricket-007-and-abbie). – OneCricketeer Jun 10 '16 at 04:05
  • You can read about [Environment Variables](http://www.computerhope.com/issues/ch000549.htm) if you want – OneCricketeer Jun 10 '16 at 04:06