Gradle error in Android Studio 0.4.3

2019-03-01 01:42发布

问题:

I found references to this with an older version, but not the most recent. I updated Android Studio to 0.4.3 and created a new project. The build fails immediately with the below:

Could not create an instance of Tooling API implementation using the specified Gradle distribution 'http://services.gradle.org/distributions/gradle-1.10-all.zip'.: Could not create an instance of Tooling API implementation using the specified Gradle distribution 'http://services.gradle.org/distributions/gradle-1.10-all.zip'.
com.intellij.openapi.externalSystem.model.ExternalSystemException: Could not create an instance of Tooling API implementation using the specified Gradle distribution 'http://services.gradle.org/distributions/gradle-1.10-all.zip'.
    at org.jetbrains.plugins.gradle.service.project.GradleExecutionHelper.execute(GradleExecutionHelper.java:185)

I have tried installing JDK 1.7 and setting my JAVA HOME to that (previously was 1.6) but the same error occurs. My GradleWrapper.properties is:

#Wed Apr 10 15:27:10 PDT 2013
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=http\://services.gradle.org/distributions/gradle-1.10-all.zip

Any ideas?

回答1:

You need to make sure you're using the correct version of the Android Gradle plugin. For Android Studio 0.4.3 it's the 0.8.X series. Specify it in build.gradle as:

dependencies {
    classpath 'com.android.tools.build:gradle:0.8.+'
}

This may be in the top-level build.gradle or the one in your module; the location where we put this has changed in projects newly created in later versions of Android Studio.