Error running android: Gradle project sync failed. Please fix your project and try again

Android Studio (1.2 RC0) keeps telling me Error running android: Gradle project sync failed. Please fix your project and try again. How can I find out what the problem is? Unfortunately the solutions from this SO thread did not help.


Solution 1:

  1. Goto File -> Invalidate caches / Restart
  2. Shutdown Android Studio
  3. Rename/remove .gradle folder in the user home directory
  4. Restart Android Studio (It will download gradle metadata and data)
  5. Gradle build succeed
  6. Rebuild project. Done.

Solution 2:

Solution is

  1. Connect your computer to the internet

  2. Click

Sync project with Gradle files

On toolbar enter image description here

It will automatically sync the gradle.

Solution 3:

Just ignore the error and try running the project anyway. It will fail, but this time you will get a link in the error description. Clicking the link will trigger the automatic update/download of the outdated/missing component.

In my scenario, the project failed to launch two times, each time another API/SDK component being the culprit.

In my case I was just trying to launch a sample project I downloaded, having no clue what API level was being targeted or where to look for this information.

Solution 4:

  1. Download the latest Gradle package distribution for example (gradle-2.11-all.zip).
  2. Extract this zip file in a folder as for example (D://Gradle)
  3. Load your project in Android Studio and go to File->Settings->Gradle. Click on Use local Gradle distribution and point it to the folder where you unzipped the latest Gradle project.
  4. Restart your project

Solution 5:

It is a very common issue and the solution is very easy... Just update the SDK in SDK manager(see full instructions below)

  1. Open Android Studio and go to your SDK Manager(File>Settings>SDK Manager)
  2. Check for (-) icon in front of any package and click on it.
  3. Click OK to start updating the SDK.

Thanks for asking that question :)