Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio - Unable to build project - GradleConnectionException

I'm on Android Studio 0.3.2. Since I upgraded from previous version, unable to build existing projects.

I'm consistently having gradle integration problems. I spend more time sorting out gradle than writing any code. I've been stumped for one week now!

I get the error mentioned on so many posts, but after reading for hours none of the solutions have worked for me.

org.gradle.tooling.GradleConnectionException: Could not execute build using Gradle installation 'C:\Users\Adrian.gradle\wrapper\dists\gradle-1.8-all\2kopnp0i5dq014k75fp36m3vd5\gradle-1.8'.: Could not execute build using Gradle installation 'C:\Users\Adrian.gradle\wrapper\dists\gradle-1.8-all\2kopnp0i5dq014k75fp36m3vd5\gradle-1.8'.

I checked my gradle version using the built in terminal window in android studio.

gradlew --version in terminal window

My gradle.xml

<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
  <component name="GradleSettings">
    <option name="linkedExternalProjectsSettings">
      <GradleProjectSettings>
        <option name="distributionType" value="DEFAULT_WRAPPED" />
        <option name="externalProjectPath" value="$PROJECT_DIR$" />
        <option name="useAutoImport" value="true" />
      </GradleProjectSettings>
      <GradleProjectSettings>
        <option name="distributionType" value="DEFAULT_WRAPPED" />
        <option name="externalProjectPath" value="D:\Users\Adrian\AndroidStudioProjects\SupaScaleProject" />
        <option name="useAutoImport" value="true" />
      </GradleProjectSettings>
    </option>
    <option name="serviceDirectoryPath" value="$USER_HOME$/.gradle" />
  </component>
</project>

My gradle-wrapper.properties

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=http\://services.gradle.org/distributions/gradle-1.8-all.zip  

My build.gradle

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

   repositories {
        mavenCentral()
}

android {
    compileSdkVersion 18
    buildToolsVersion "18.1.1"

    defaultConfig {
        minSdkVersion 14
        targetSdkVersion 18
    }

    buildTypes {
        release {
            runProguard true
            proguardFile getDefaultProguardFile('proguard-android-optimize.txt')
        }

        debug {
            runProguard false
            proguardFile getDefaultProguardFile('proguard-android-optimize.txt')
        }
    }

 }

dependencies {
    compile 'com.android.support:support-v4:13.0.+'
    compile files('libs/achartengine-1.1.0.jar')
}

I do a build from the Terminal: gradlew compileDebug and the build is successful!

enter image description here

Now I build form the Menu bar Build -> Rebuild Project (in AndroidStudio 0.3.2):

enter image description here

I really don't know where to look anymore. Any help will be appreciated.

Oh .. yes I have deleted all the files in .gradle/wrapper/dists/ and allowed Android Studio to download for me.

Thanks in advance.

Adrian

Following @joucks comment, I noticed the following at http://tools.android.com/knownissues:

enter image description here

So I changed my build.gradle to classpath 'com.android.tools.build:gradle:0.6.3' unfortunately still the same result.

Thereafter I updated the compileSDKVersion to 19, and the buildToolsVersion to "19.0.0", hoping for some success. Unfortunately none. Yes .. and before you ask, my SDK-Manager is up to date with all the latest files.

like image 749
Adrian Wreyford Avatar asked Nov 08 '13 13:11

Adrian Wreyford


1 Answers

I finally figured this one out. Both times this has happened to me, rebooting my computer made it go away. "GradleConnectionException" must happen because of some memory leak or resource issue in windows.

like image 178
Kevlar Avatar answered Oct 22 '22 08:10

Kevlar