In Android Studio, I am getting the following error when trying to run my app on an Android device:

The specified Gradle distribution 'https://services.gradle.org/distributions/gradle-7.2-bin.zip' does not exist.

All my Android Studio projects are affected by this and restoring them to older commits does not change anything.

The problems all started by following the advice given here: Could not install Gradle distribution from 'https://services.gradle.org/distributions/gradle-2.1-all.zip'

I deleted everything in my /.gradle/wrapper/dists/ folder. Now, I get the above error and I do not see how to solve it.

Here is how to reproduce it with Android Studio 2021.1.1 on Windows (but be warned: this might corrupt your projects, too):

  1. Delete everything in /.gradle/wrapper/dists/
  2. Create a new project "Test" in Android Studio (this might take a while, since gradle-7.2-bin.zip will be downloaded in the dists folder)
  3. The project builds and runs without errors
  4. Close Android Studio
  5. Delete everything in /.gradle/wrapper/dists/ again
  6. Open project "Test" in Android Studio
  7. Try to run

Now you should get the above mentioned error.

At this point, /.gradle/wrapper/dists/ is still empty. Now you can do the following:

  1. run gradlew tasks in Terminal in the Project Folder of "Test" (this will take a while, since gradle-7.2-bin.zip will be downloaded in the dists folder again)
  2. run gradlew build (everything should build without errors)

But clicking on "Run" still yields the same error.

I am getting the impression that this is an AndroidStudio / IntelliJ bug.

Can anyone help me with this?

2

There are 2 best solutions below

0
On

Running Android Studio as Administrator solved the problem for me

0
On

It turned out my Android Studio installation was heavily corrupted. Simply, uninstalling it and installing it again also did not help.

I basically had to do everything that was suggested here: How to completely uninstall Android Studio from windows(v10)? and delete everything related to Android Studio. I installed it again and now everything is fine again.

I do not know what the problem was. Maybe the .m2 folder, maybe the Jetbrains folder.

My advice to everyone facing the same issue: First try around deleting caching folders. If nothing helps, go for the brute force approach and follow the answers (not only the accepted answer) of the above mentioned StackOverflow question.