[android] 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?

This question is related to android gradle android-studio

The answer is


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.


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


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 :)


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.


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.


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.+

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.


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

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. 

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.


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


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.


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.


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.


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.


For me the following two steps fixed the issue:

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

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.


Examples related to android

Under what circumstances can I call findViewById with an Options Menu / Action Bar item? How to implement a simple scenario the OO way My eclipse won't open, i download the bundle pack it keeps saying error log getting " (1) no such column: _id10 " error java doesn't run if structure inside of onclick listener Cannot retrieve string(s) from preferences (settings) strange error in my Animation Drawable how to put image in a bundle and pass it to another activity FragmentActivity to Fragment A failure occurred while executing com.android.build.gradle.internal.tasks

Examples related to gradle

Gradle - Move a folder from ABC to XYZ A failure occurred while executing com.android.build.gradle.internal.tasks Gradle: Could not determine java version from '11.0.2' Android Gradle 5.0 Update:Cause: org.jetbrains.plugins.gradle.tooling.util Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0 Failed to resolve: com.android.support:appcompat-v7:28.0 Failed to resolve: com.google.firebase:firebase-core:16.0.1 com.google.android.gms:play-services-measurement-base is being requested by various other libraries java.lang.NoClassDefFoundError:failed resolution of :Lorg/apache/http/ProtocolVersion Error - Android resource linking failed (AAPT2 27.0.3 Daemon #0)

Examples related to android-studio

A failure occurred while executing com.android.build.gradle.internal.tasks "Failed to install the following Android SDK packages as some licences have not been accepted" error Android Gradle 5.0 Update:Cause: org.jetbrains.plugins.gradle.tooling.util This version of Android Studio cannot open this project, please retry with Android Studio 3.4 or newer WARNING: API 'variant.getJavaCompile()' is obsolete and has been replaced with 'variant.getJavaCompileProvider()' Flutter plugin not installed error;. When running flutter doctor ADB.exe is obsolete and has serious performance problems Android design support library for API 28 (P) not working Flutter command not found How to find the path of Flutter SDK