29

I have two projects. One project is working without any issues. It was downloaded from gitlab. The other project was downloaded from github. github project has this issue. I want to use default gradle distribution. I want to know what wrong I did. Using local gradle distribution builds the project. But i get other issue - Precondition class not found. This issue is not my question here. Also I dont know if the gradle (local distribution or default) is causing the issue. Those things aside. I just want to know why I am getting - The specified Gradle distribution 'https://services.gradle.org/distributions/gradle-4.6-all.zip' does not appear to contain a Gradle distribution.

My team mates are not having any problem. They are running the project without any issues. The project which is building correctly used gradle 4.10.1. This project uses 4.6.

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

Zoe
  • 27,060
  • 21
  • 118
  • 148
Vijai Gunasekar
  • 383
  • 1
  • 3
  • 13

5 Answers5

47

I was able to solve this issue by upgrading the Gradle Version (not the Android Gradle Plugin Version). Go to Project Structure -> Project example here

After this, Gradle re-downloaded all dependencies and the build was successful.

miguelarc
  • 791
  • 7
  • 13
  • 12
    For anyone that still has issues, or wants to keep the same version, try deleting the Gradle-wrapper at `$HOME/.gradle/wrapper/dists/`. After that, try syncing the project. NOTE: while deleting the Gradle-wrapper, you will need to close AS. – miguelarc Sep 06 '19 at 13:48
  • thanks for your answer. but i solved it by adding multidex support – Vijai Gunasekar Sep 13 '19 at 09:46
  • thanks @miguelarc, your suggestion working on my case.. i think that's other solution.. – Nurkartiko Dec 13 '19 at 07:42
  • @VijaiGunasekar Since this answer is working for most people facing this particular error, you may want to consider it as one possible correct (even if it didn't apply for your specific case). Don't know if SO allows for multiple correct answers. – miguelarc Jan 29 '20 at 14:30
  • 3
    I copied the gradle number from working project and paste at the above specified location in the project which has problem , now resolve the issues. – Vishwa Pratap Mar 29 '20 at 00:16
  • Does anybody know why this happens though? It's a shame that a project that worked before without any local changes would suddenly stopped being able to build itself a couple of months later. – Andrew Lim May 18 '20 at 07:03
  • @miguelarc thanks so much! That worked great. I was in the same boat as Andrew, where a working project suddenly wouldn't build... – You'reAGitForNotUsingGit Jul 03 '20 at 14:03
  • 1
    @AndrewLim my guess is certain Gradle references won't get updated when Gradle is updated. Once a new version is installed, Gradle is still looking for old references, hence the errors. It has happened to me in different versions in the past. – miguelarc Feb 19 '21 at 14:52
16

I managed to fix this by updating the gradle version number in Project Structure in Android Studio 3.4.1

File -> Project Structure -> Project -> Gradle Version

Amin Keshavarzian
  • 3,646
  • 1
  • 37
  • 38
8

The only think that works for me was:

  1. Click on the error link to download the gradle zip.

  2. Then go to C:\Users\YourUsername\.gradle\native and drop the content of the zip.

  3. Open AndroidStudio, go to File->Settings->Build,Execution,Deployment->Gradle

  4. Change "Use Gradle from:" to "Specified location" and paste the direction C:\Users\YourUsername\.gradle\native\NameOfTheZipContent

  5. Apply, Ok

  6. Sometimes needs to open/close AndroidStudio

Lotan
  • 4,078
  • 1
  • 12
  • 30
6

Well, I tried all of the above solutions except for miguelarc's second solution, then I closed it and 'run android studio as administrator'(by right clicking on the icon), and it auto downloaded the gradle files just fine. No messing around with the files or change in settings were required for me.

Nestachio
  • 69
  • 1
  • 3
3

I have resolved the same problem. Try to exit Android Studio. Then, open again with "Run as administrator"

Thào A Vảng
  • 397
  • 4
  • 7
  • 3
    never, ever, run Android Studio as administrator. If this "fixes" it is a permission issue, you should fix the permission issue instead – Daniele Segato Oct 05 '22 at 07:04