Solution 1: Delete the .android folder in the Mac user folder and the .gradle file in the project root directory folder; then try invalidate cache and restart in Android Studio to see if it can be solved;
Solution 2: Change the gradle-wrapper.properties file in the gradle folder of the project root directory
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zipfor
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
I have solved this problem here. Of course, you can assign values according to the actual situation.