UPDATE 2021
This should be the accepted answer as its easy and upto date
AndroidSDK can finally accept licenses.
Go to Android\sdk\tools\bin
yes | sdkmanager --licenses
EDIT:
as pointed out in the comments by @MoOx, on macOS, you can do
yes | sudo ~/Library/Android/sdk/tools/bin/sdkmanager --licenses
as pointed out in the comments by @pho, @mikebridge and @ Noitidart on Windows, you can do
cmd.exe /C"%ANDROID_HOME%\tools\bin\sdkmanager.bat --licenses"
be sure to install java before