Since gradle android plugins 2.2-alpha4:
Gradle will attempt to download missing SDK packages that a project depends on
Which
I had same issue but none of the answers posted helped since there was no tools folder present in Library/Android/sdk. (I'm using Android 3.6.3 on Mac OS 10.14.4)
Below steps helped me to overcome licensing problem error:
Android Studiocmd + shift + A. This opens Actions pop-up window.SDK Manager and hit enter to open.Android SDK. Select some other version of Android apart from already installed one. (In my case Android 10.0 was already installed so I selected Android 9.0) Apply button. This will install corresponding SDK.