Could not execute build using Gradle installation/distribution

Hello all, I have been developing Android app with Intellij IDEA on Mac. Currently I need to also work on
PC but I have difficulties in setting up a project in Intellij IDEA on PC (Windows 7). I can’t get passed the error message saying:

Error:Android
Gradle Build Target: org.gradle.tooling.GradleConnectionException: 
Could not execute build using Gradle distribution 'https://services.gradle.org/distributions/gradle-2.2.1-all.zip'. 

or if I set it to my local gradle installation, it says:

Error:Android
Gradle Build Target: org.gradle.tooling.GradleConnectionException: 
Could not execute build using Gradle installation 'C:\Program Files\gradle-2.4'. 

Tried few solutions offered by people who got similar problems and solved theirs, but it won’t solve mine. Even a simple new project setup won’t get passed this error. Anything that I missed?

Details of my setups: OS: Windows 7 64BitIntellij IDEA 14.1.3JDK 1.8.0_40I also installed Gradle locally in order to try solving this issue Tried invalidate caches/restart, deleted .gradle folder, turn on/off “Use auto-import”, alternating “Use default gradle wrapper”, “User customizable gradle wrapper”, “Use local gradle distribution”. None of them works.

settings.gradle at the root of my project folder:

include ':app'

build.gradle at the root of my project folder:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.1.1'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}
 build.gradle at my app folder buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.1.1'
    }
}
apply plugin: 'com.android.application'

repositories {
    jcenter()
}

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.1"

    defaultConfig {
        applicationId "com.flake.myapplication2.app"
        minSdkVersion 9
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_6
        targetCompatibility JavaVersion.VERSION_1_6
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:21.0.2'
}

I also see some messages “dependencies cannot be applied to groovy.lang.Closure” if that’s related. Thank you for your help.

1 Like

I am also facing the same problem.

1 Like