If you have installed the latest cmd-line tools from Android Studio, but it still gives the error, then you should do the following.
If you have installed the Android SDK to a custom directory, then you need to copy the path of your SDK folder. Then you have to go to the edit environment variable, click New give
a variable name: ANDROID_SDK_ROOT. And a variable value: path of your SDK folder.
Click OK.
In the older version of Flutter, this error came with the solution (creating ANDROID_SDK_ROOT), but in the new versions it does not show that.