user2233215
user2233215

Reputation: 645

Gradle error: could not execute build using gradle distribution

After I updated Android Studio to version 0.2.7, I got the following error:

 org.gradle.tooling.GradleConnectionException: Could not execute build
 using Gradle distribution
'http://services.gradle.org/distributions/gradle-1.6-bin.zip'.: Could
 not execute build using Gradle distribution
'http://services.gradle.org/distributions/gradle-1.6-bin.zip'.

This is my build.gradle:

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.5.+'
    }
}
apply plugin: 'android'

dependencies {
    compile files('libs/android-support-v4.jar')
}

android {
    compileSdkVersion 17
    buildToolsVersion "17.0.0"

defaultConfig {
    minSdkVersion 10
    targetSdkVersion 17
}
}

Does anyone know this error?

Upvotes: 53

Views: 151467

Answers (17)

mohamed ayed
mohamed ayed

Reputation: 648

      1- delete .gradle folder in the root directory of the app
      2- invalidate cache and restart 

Upvotes: 3

shivpal jodha
shivpal jodha

Reputation: 102

I had the same issue and i solved it by deleteing gradle-wrapper.jar and gradle-wrapper.properties file of Gradle wrapper then clean rebuild work for me.

Upvotes: 1

Oush
Oush

Reputation: 3348

This problem occurred to me when I edited the configurations in Android Studio to use the Desktop. However, using the default(android) seems to work well without any issues.

Upvotes: 0

To correct this mistake very easily, If you read logs. The problem occurs because of the sudden shutdown of the IDEA. And the log files do not correctly write data. Just delete the file on the path

C:/Users/{UserName}/.Gradle/demon/{gradleVersion}/registry.bin.lock. 

Upvotes: -1

Mark Fidell
Mark Fidell

Reputation: 1123

I had the same issue, can't say I know what caused it, but I just closed Android Studio, renamed the c:\users\MY USERNAME\.gradle directory to old-.gradle and then re-launched Android Studio.

Android studio then re-created the directory and automatically downloaded the gradle zip file and set it all up.

Seems to all be fine but to be honest I don't know what this directory is nor what the root cause of the problem was either, so proceed with caution and keep the old .gradle folder around for a bit until you're happy all is working fine.

Upvotes: 63

JnBrymn
JnBrymn

Reputation: 25363

I had a similar problem after doing brew install gradle. Perhaps it was because it was an older version. So I uninstalled and instead followed the gradle website's install instructions and then when I did gradle eclipse I no longer had the could not execute build using gradle distribution error.

Upvotes: 0

devJackie
devJackie

Reputation: 119

First of all, JDK environment variable settings :

e.g) JAVA_HOME -> C:\develop\java\jdk\jdk1.8.0_25 path -> %JAVA_HOME%\bin;

eclipse Window -> preferences -> Gradle -> Arguments -> Worksapce JRE check -> jdk(jdk1.8.0_25) choice

again Run -> gradle build :)

Upvotes: 5

Sahan Jayasumana
Sahan Jayasumana

Reputation: 450

This happened to me after a java update, few things to check if you are sure your path has been set before:

  1. if the path doesn't match the latest java install folder, change it (if your in eclipse check the eclipse.ini too to make sure your using your systems default vm (ie no VM tag) )

  2. go to the java directory, there should be a 'jdk' and a 'jre' in the path, for example:

    C:\Program Files (x86)\Java\jdk1.8.0_72\jre
    

    if not you probably installed the JRE only not the JDK that

  3. finally if the lib folder of the jdk (not jre) doesnt contain tools.jar then you have a problem with the install

Upvotes: 0

Jess
Jess

Reputation: 1

I had the same Gradle build problems in Eclipse and by doing the following steps, the problems were solved:

  • set up project to use correct java version of java project properties-> java build path -> jre system (edit the current one, and add the correct java jdk or jre there)

  • window->Preferences ->Gradle->Arguments-> Workspace JRE (set to the correct one)

Hope this will help those who have the same problems.

Upvotes: 0

rubo77
rubo77

Reputation: 20845

I had the same problem on Ubuntu with Eclipse 4.3 (Kepler) and the problem was that I created the project with a minus-sign in it.

I recreated the project with no specialchars and it all worked fine

Upvotes: 0

John Bentley
John Bentley

Reputation: 1824

For me, when using IntelliJ IDEA, this error arose because I had the Java SDK, rather than an Android SDK, set at the Project level.

My fix:

  • IntelliJ > File > Project Structure ...
  • Project > Project SDK > [Select] 'Android API 19 Platform (java version "1.7.0_40")'

I'm on:

  • IntelliJ IDEA: 13.1.3
  • Gradle: 1.10
  • Android Plugin for Gradle: 0.9.+

Upvotes: 0

neo
neo

Reputation: 164

I entered: [C:\Users\user\].gradle\caches\1.8\scripts directory and deleted its content. I didn't had to restart anything, just removed scripts content any rerun it.

Upvotes: 0

SharkAlley
SharkAlley

Reputation: 11659

As per answer by WarrenFaith, go to:

Settings -> Gradle -> Project-level settings

Change to Use customizable gradle wrapper.

Click OK and watch it build. If you still get an error at that stage, go back to:

Settings -> Gradle -> Project-level settings 

Change it back to Use default gradle wrapper (recommended)

Click OK. That fixed it for me.

Upvotes: 1

maxb3k
maxb3k

Reputation: 358

For me the following two steps fixed the issue:

  1. Make sure the Gradle build was successful
  2. Android Studio - File - Invalidate Caches / Restart...

Upvotes: 14

Ryan Heitner
Ryan Heitner

Reputation: 13632

I suddenly had this issue in the morning after it working the night before. I tried all solutions here and failed.

I also tried installing another version of Gradle 1.8 and setting the gradle_home.

Tried restarting studio.

Eventually the tried and trusted method of restarting Windows worked for me.

All in all a frustrating waste of time.

Upvotes: 8

WarrenFaith
WarrenFaith

Reputation: 57672

I had this issue as well and jaywhy13 answer was good but not enough.

I had to change a setting: Settings -> Gradle -> MyProject

There you need to check the "auto import" and select "use customizable gradle wrapper". After that it should refresh gradle and you can build again. If not try a reboot of Android Studio.

Upvotes: 5

jaywhy13
jaywhy13

Reputation: 1116

I updated to 0.3.0 and had the same issue. I had to end up changing my Gradle version to classpath 'com.android.tools.build:gradle:0.6.1+' and in build.gradle and also changing the distributionUrl to distributionUrl=http\://services.gradle.org/distributions/gradle-1.8-bin.zip in the gradle-wrapper.properties file. Then I did a local import of the Gradle file. That worked for me.

Upvotes: 5

Related Questions