This issue happens when your gradle version mismatched with the classpath or other libraries you are using in the android project. For android, Flutter and react native developers will face this issue when you are updating libraries or frameworks.
To fix this we will need to update the binaries to the most upto date version. To do that.
1. Open the
gradle-wrapper.properties file from the project folder of your Android studio or favourite editor.
2. Find the line containing gradle binary distribution URL
Note that the version of your distribution should be visible in the error.
3. Update the version to the most up to date version
Here I will update this to 7.0 version
Then run or build the code and it will run smoothly without this error.