gradle directory trouble

If you ever move an Android Studio project, you’ll probably notice that Gradle will get mad at you for a while. This is also true if you try to git clone a project to another computer, for example.

Gradle ‘Android’ project refresh failed:
Could not execute build using Gradle distribution ‘http://services.gradle.org/distributions/gradle-1.8-bin.zip’.
Project directory ‘<old_directory>’ does not exist.

It  tries to help you out by providing a link to a dialog where, ostensibly, the issue can be resolved.

Gradle

Unfortunately, there is no field in this window that applies to the broken setting. I’m sure this oversight will be resolved in a later Android Studio release, but until then, you can fix the issue by editing /.idea/gradle.xml within your project directory. Set the externalProjectPath option to the appropriate value. Problem solved!