got it resolved:
uninstall the entire android studio
rm -Rf /Applications/Android\ Studio.app
rm -Rf ~/Library/Preferences/AndroidStudio*
rm -Rf ~/Library/Preferences/com.google.android.*
rm -Rf ~/Library/Preferences/com.android.*
rm -Rf ~/Library/Application\ Support/AndroidStudio*
rm -Rf ~/Library/Logs/AndroidStudio*
rm -Rf ~/Library/Caches/AndroidStudio*
rm -Rf ~/.AndroidStudio*
rm -Rf ~/.gradle
rm -Rf ~/.android
rm -Rf ~/Library/Android*
rm -Rf /usr/local/var/lib/android-sdk/
rm -Rf /Users/<username>/.tooling/gradle
Remove your project and clone it again and then goto Gradle Scripts
and open gradle-wrapper.properties
and change the below url which ever version you need
distributionUrl=https\://services.gradle.org/distributions/gradle-4.2-all.zip