Specify Gradle version for Eclipse

Trying to import Gradle project into Eclipse, got an error

FAILURE: Build failed with an exception.

  • Where:
    Build file ‘myProject\build.gradle’ line: 3
  • What went wrong:
    Could not compile build file ‘myProject\build.gradle’.

    startup failed:
    build file ‘myProject\build.gradle’: 3: unable to resolve class org.apache.ivy.plugins.resolver.URLResolver
    @ line 3, column 13.
    add(new org.apache.ivy.plugins.resolver.URLResolver()) {
    ^

Cause

Gradle version incompatibility – the URLResolver requires Gradle version 2.0 or lower.

Gradle version – If you do not specify a Gradle version, Eclipse uses the latest from services.gradle.org, which is 2.2 at time of posting.

Solution

To specify the version, add a folder “gradle” and underneath it another folder called “wrapper”. Then add a file “gradle-wrapper.properties” in the wrapper folder


myProject
..|_ gradle
......|wrapper
.........|
gradle-wrapper.properties

like the above structure.

In gradle-wrapper.properties, put
distributionUrl=http://services.gradle.org/distributions/gradle-1.11-all.zip

Save the file.

In this case I am using 1.11. You may pick your version from https://services.gradle.org/distributions

Eclipse will use the specified version to build. Viola, no more errors. 🙂

 

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s