Since gradle android plugins 2.2-alpha4:
Gradle will attempt to download missing SDK packages that a project depends on
Which
For those having issues with the command line SDK, the reason it won't find the licenses you have accepted is because they have have been written to a different location than $ANDROID_HOME/licenses
which is where they need to be.
I found the easiest solution was to accept the licenses like this:
$ANDROID_HOME/bin/sdkmanager --licenses --sdk_root=$ANDROID_HOME
Note: This assumes you've set ANDROID_HOME
to point to wherever your sdk is installed.