1

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?

James
  • 999
  • 2
  • 11
  • 22
  • 1
    Are you specifying v0.8 of the plugin in your build.gradle? – Scott Barta Jan 29 '14 at 20:05
  • possibly duplicate of http://stackoverflow.com/questions/21330021/gradle-error-when-pressing-run-app-android-studio/21330597#21330597 – Piyush Agarwal Jan 29 '14 at 20:08
  • @ScottBarta thanks- that was changed to 0.10 somehow (probably me) - changed it back to 0.8. Can now build from the command line running gradlew, but making the project in Android Studio still fails... progress though! – James Jan 29 '14 at 20:10
  • Added as an official answer. – Scott Barta Jan 29 '14 at 20:13
  • @James have you checked the files mentioned in the link i have posted. – Piyush Agarwal Jan 29 '14 at 20:15
  • @pyus13 those steps made no difference unfortunately. – James Jan 29 '14 at 20:19
  • not sure but you can try `File > Invalidate Cache and Restart` because as you mentioned you are able to create builds using command linebut not from studio. – Piyush Agarwal Jan 29 '14 at 20:25
  • Did that. The errors android studio gives now are: 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 implementation of service 'org.gradle.tooling.internal.protocol.ConnectionVersion4'. Could not create an instance of type org.gradle.tooling.internal.provider.DefaultConnection. Cannot inherit from final class – James Jan 29 '14 at 20:30
  • The link i have posted in comments above can help you now. Try that once. Check this http://stackoverflow.com/questions/21213487/cannot-inherit-from-final-class/21213727#21213727 – Piyush Agarwal Jan 29 '14 at 21:11

1 Answers1

2

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.

Scott Barta
  • 79,344
  • 24
  • 180
  • 163
  • That seems to let me now build at the command prompt, but not from within android studio - I'll keep fiddling but it's definitely helped a bit! This is in the top level build.gradle, the one in the project doesn't have that line. – James Jan 29 '14 at 20:20
  • @Scott These gradle versions are a big point of confusions and build errors, why cant AS handle these all by it own, if it knows whats wrong there. – Piyush Agarwal Jan 29 '14 at 20:21
  • It's supposed to -- it actually checks the plugin and Gradle versions at project load time and offers corrections if the versions are wrong. There's a wrinkle that a Gradle-internal API we use to do that version check changed between two versions of Gradle (1.8 and 1.9, if my memory serves me), and it fails before it can even do that version check. I think this failure propagates across some versions of the Android plugin as well, and I think that's what's happening here. I agree this is a really confusing problem, and we definitely want to get it properly fixed. – Scott Barta Jan 29 '14 at 20:24
  • ohh ya I know that it is mentioned somewhere in the reported bugs for Android Studio and also explained by Alex :( hope you guyz will find some workaround soon. – Piyush Agarwal Jan 29 '14 at 20:33
  • I'm marking this as correct, as it certainly got the command-line gradle build working. I've now gone for the nuclear option as I didn't have much to lose anyway, and it's building in Android Studio now too. – James Jan 30 '14 at 10:23