72

I've just updated Android Studio and I can't sync my project anymore.

The event log reports:

Gradle sync failed: /Applications/Android Studio.app/Contents/gradle/gradle-X.X.X/lib/plugins/gradle-diagnostics-X.X.X.jar (No such file or directory)
araks
  • 40,738
  • 8
  • 34
  • 39

8 Answers8

175

To solve the Gradle sync error, open gradle-wrapper.properties file and update the Gradle wrapper distribution version from:

distributionUrl=https\://services.gradle.org/distributions/gradle-X.X.X-all.zip

To:

  • Android Studio 3.4 distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
  • Android Studio 2.3 distributionUrl=https\://services.gradle.org/distributions/gradle-2.3-all.zip
  • Android Studio 2.2 distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
  • Android Studio 2.1 distributionUrl=https\://services.gradle.org/distributions/gradle-2.12-all.zip
  • Android Studio 2.0 distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
  • Android Studio 1.5 distributionUrl=https\://services.gradle.org/distributions/gradle-2.8-all.zip
  • Android Studio 1.3 distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip


You can find the latest Gradle wrapper version visiting: https://services.gradle.org/distributions/


EDIT:
As a side note, as @SeBsZ suggests, the official repository of the Android Gradle plugin switched from MavenCentral to jCenter (see Bintray blog post).

Make sure your project build.gradle file contains the new repository and the new classpath:

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

allprojects {
    repositories {
        jcenter()
    }
}

This is not strictly related to the question problem, but since we are already migrating to the new IDE preview it's better to make sure everything is in place.

araks
  • 40,738
  • 8
  • 34
  • 39
  • That did not work for me. What distro are you using? – Menno van Leeuwen May 29 '15 at 10:41
  • @КодСерфинг145 I'm on Mac OS X, have you tried to Build>Clean and then resync your project? Thank you for your feedback! – araks May 29 '15 at 10:44
  • For me moving Android-studio to /opt/android-studio worked but this is probably only working on linux. I'm using Play Linux (Insider build) – Menno van Leeuwen May 29 '15 at 12:57
  • @КодСерфинг145 yes, installing Android Studio on /opt/android-studio is the best practice on Linux. Please see the updated answer to configure the correct Gradle wrapper and Android Gradle Plugin versions. Have a nice day! – araks May 29 '15 at 13:02
  • 3
    **Note for troubleshooting**: *gradle-wrapper.properties* is not visible if you are viewing as *Project*. It is easy to find under *Gradle Scripts* if you switch to the *Android* view. – Phil May 29 '15 at 16:48
  • I had to do the opposite: Change from gradle-2.4-all.zip to gradle-2.2.1-all.zip... – Roar Skullestad Nov 06 '15 at 10:17
  • 1
    thank you. just updated and. studio to 1.5 and updated gradle.properties to distributionUrl=https\://services.gradle.org/distributions/gradle-2.9-all.zip and it worked nicely (NOV 2015) – DoruChidean Nov 20 '15 at 10:47
  • 1
    FYI - For Studio 1.5, had to use Gradle 2.8, not 2.9. So distributionUrl=https\://services.gradle.org/distributions/gradle-2.8-all.zip instead of distributionUrl=https\://services.gradle.org/distributions/gradle-2.9-all.zip. In case 2.9 doesn't work for you... – Bourne Nov 20 '15 at 16:14
  • This happened when I upgraded the Android Studio and the Parse Starter project stopped working. Thanks for your help! – C0D3 Dec 21 '15 at 16:14
  • 4
    ps: Android Studio 2.3 use gradle-3.3-all.zip – actsai Mar 16 '17 at 07:58
2

If, like me, you are using an older project then you might still be using the maven repository. Make sure you change the repositories in your top-level build.gradle from maven() to jcenter(). Then make sure you are using the correct dependency as well: classpath 'com.android.tools.build:gradle:1.3.0-beta1' for the new 1.3 preview.

SeBsZ
  • 485
  • 4
  • 8
  • I think this solution is a bit out of topic (the question is specific to the erroneous Gradle plugin version). Maybe you should post another question for the Maven-related problem you experienced! Anyway, thank you for your contribution: I'll check the classpath thing as soon as I'm back in office! – araks May 29 '15 at 11:41
1

For me helped to set chmod on the .gradle directory to 777. After this whole Android studio started working correctly.

redrom
  • 11,502
  • 31
  • 157
  • 264
1

I got the same issue after updating android studio to 3.4

I resolve this updatig gradle-wrapper.properties

I had

distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip

I leave

distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip

and with this To solve the Gradle sync error.

Adolfo Rangel
  • 71
  • 1
  • 3
0

This is the weirdest thing ever and I never expected it to work but this:

distributionUrl=https://services.gradle.org/distributions/gradle-2.2.1-all.zip

worked and got everything fixed (it was the '\' after https). It does make sense since that is an actual link to a file.

C.Farrugia
  • 4,116
  • 3
  • 14
  • 12
0

check your .bash_profile file and make sure your GRADLE_HOME points to a valid path, if things were working and you face this issue after android studio update, chances are your gradle got updated too. Here is the example of my gradle home in .bash_profile: export GRADLE_HOME=/Applications/Android\ Studio.app/Contents/gradle/gradle-2.14.1/bin

karma
  • 1,282
  • 18
  • 23
0

Had the same problem with a newly set up Android Studio 2.2.2, gradle wrapper 2.14.1. I loaded the project before i installed the needed android-23 library and installed java after Android Studio installation.

Error message in Android Studio 2.2.2:

Error:The specified Gradle distribution
'https://services.gradle.org/distributions/gradle-2.14.1-all.zip' does 
not appear to contain a Gradle distribution.

Error message in cmd:

projectfolder> gradlew
Exception in thread "main" java.lang.NullPointerException
at org.gradle.wrapper.BootstrapMainStarter.findLauncherJar(BootstrapMainStarter.java:34) 
at org.gradle.wrapper.BootstrapMainStarter.start(BootstrapMainStarter.java:25)
at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:129)
at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61)

When i used gradle from cmd however it worked

projectfolder> set PATH=%PATH%;C:\AndroidStudio2.0\gradle\gradle-2.14.1\bin\
projectfolder> set GRADLE_HOME=C:\AndroidStudio2.0\gradle\gradle-2.14.1\bin\
projectfolder> cd C:\projectfolder\
projectfolder> gradle
BUILD SUCCESSFUL

In cmd i see that the gradle versions and android sdk version were correct

C:\>set | find "JAVA_HOME"
JAVA_HOME=C:\Java\jdk1.8.0_111\

However in C:\Users\.AndroidStudio2.2\system\log\idea.log it said something else:

2016-11-29 16:04:10,597 [ 107684]   INFO - s.plugins.gradle.GradleManager - Instructing gradle to use java from C:/AndroidStudio2.0/jre 
2016-11-29 16:04:10,597 [ 107684]   INFO - s.plugins.gradle.GradleManager - Instructing gradle to use java from C:/AndroidStudio2.0/jre 

After messing up Android Studio config files i ended up reinstalling everything in correct order (Java, Android Studio, Project) and it worked.

vasquez
  • 449
  • 6
  • 8
-3

I got the same issue after updating my android studio to 1.5

Here is my error stack trace.

Error:A problem occurred configuring root project 'Kargo'.

java.io.FileNotFoundException: /home/adiyatmubarak/Documents/android-studio/gradle/gradle-2.4/lib/plugins/gradle-diagnostics-2.4.jar (No such file or directory)

After I checked to the android studio instalation directory within gradle, my gradle was gradle-2.8 I don't know how to setup my android studio path location, but for temporary fix I just rename it to gradle-2.4 and my problem solved.

Adiyat Mubarak
  • 10,279
  • 4
  • 34
  • 50