Android Studio 3 Error: Gradle project sync failed. Basic functionality (e.g. editing, debugging) will not work properly

When I tried to open an Android project with Android 3 that I probably created with Android Studio 2 and haven’t worked on in about two years, I got this error message:

Android Studio 3 Error: Gradle project sync failed. 
Basic functionality (e.g. editing, debugging) will not work properly

There may be many reasons for this error message, but in my case it was because my “Gradle Version” in the Project Structure was set to 2.2.1. Once I changed it to 4.10.1, everything magically worked. (I had to update several other settings as well, but after that everything worked fine.)

For the record I changed that setting like this:

  • File > Project Structure
    • Project
      • Gradle version (change this from 2.2.1 to 4.10.1)

It’s worth mentioning that most attempts to build or sync the Android project just hung up, nothing happened at all, and there weren’t any useful error messages. At some point I changed something in the old project to get to the point of getting this error message, which eventually helped me solve this problem.