I recently needed to accept Android SDK licenses on a Jenkins build server over ssh. Here’s a one-liner (you may not have to set JAVA_HOME but I had to)
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_171.jdk/Contents/Home ~/Library/Android/sdk/tools/bin/sdkmanager --licenses