I was trying to open an old GitHub project with the latest android studio that‘s why got this error. I tried almost all the way that mentions in this post but none of them is work.
In my case, I update my Gradle version with my latest project, and the issue resolved. Use your latest Gradle version to resolve the issue.