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?


Solution 1:

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.

Solution 2:

For me the following two steps fixed the issue:

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