Why are the licenses not accepted for Android SDK Platform 26 and Android SDK Build Tools 27.0.1?

I can't seem to run the android module, and I get the following:

$ cordova run android
Android Studio project detected
cordova-android-support-gradle-release: Android platform: V7+
cordova-android-support-gradle-release: Wrote custom version '27.+' to /path/to/platforms/android/app/build.gradle
cordova-android-support-gradle-release: Wrote custom version '27.+' to /path/to/platforms/android/cordova-android-support-gradle-release/norsan-cordova-android-support-gradle-release.gradle
ANDROID_HOME=/usr/lib/android-sdk
JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
studio
Subproject Path: CordovaLib
Subproject Path: app
publishNonDefault is deprecated and has no effect anymore. All variants are now published.
Observed package id 'build-tools;debian' in inconsistent location '/usr/lib/android-sdk/build-tools/27.0.1' (Expected '/usr/lib/android-sdk/build-tools/debian')
Observed package id 'build-tools;debian' in inconsistent location '/usr/lib/android-sdk/build-tools/27.0.1' (Expected '/usr/lib/android-sdk/build-tools/debian')
Checking the license for package Android SDK Build-Tools 27.0.1 in /usr/lib/android-sdk/licenses
Warning: License for package Android SDK Build-Tools 27.0.1 not accepted.
Checking the license for package Android SDK Platform 26 in /usr/lib/android-sdk/licenses
Warning: License for package Android SDK Platform 26 not accepted.

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':CordovaLib'.
> You have not accepted the license agreements of the following SDK components:
  [Android SDK Platform 26, Android SDK Build-Tools 27.0.1].
  Before building your project, you need to accept the license agreements and complete the installation of the missing components using the Android Studio SDK Manager.
  Alternatively, to learn how to transfer the license agreements from one workstation to another, go to http://d.android.com/r/studio-ui/export-licenses.html

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

* Get more help at https://help.gradle.org

BUILD FAILED in 5s
/path/to/platforms/android/gradlew: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':CordovaLib'.
> You have not accepted the license agreements of the following SDK components:
  [Android SDK Platform 26, Android SDK Build-Tools 27.0.1].
  Before building your project, you need to accept the license agreements and complete the installation of the missing components using the Android Studio SDK Manager.
  Alternatively, to learn how to transfer the license agreements from one workstation to another, go to http://d.android.com/r/studio-ui/export-licenses.html

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

* Get more help at https://help.gradle.org

BUILD FAILED in 5s

It looks like specific paths on my system are not what the androidsdk program expected, and I'm unsure if I should manually create these paths or if I should look further with what I can do with package managers and installations.

So I try:

$ androidsdk "build-tools;27.0.1" "platforms;android-26"
SDK_ROOT=/home/galen/snap/androidsdk/21/AndroidSDK
Picked up _JAVA_OPTIONS: -Duser.home=/path/to/snap/androidsdk/21
Warning: File /path/to/snap/androidsdk/21/.android/repositories.cfg could not be loaded.
[=======================================] 100% Computing updates...

But I still get the same error afterward. I'm not sure if the warning relevant or not.

I've also tried:

$ androidsdk --licenses
SDK_ROOT=/path/to/snap/androidsdk/21/AndroidSDK
Picked up _JAVA_OPTIONS: -Duser.home=/path/to/snap/androidsdk/21
Warning: File /home/galen/snap/androidsdk/21/.android/repositories.cfg could not be loaded.
All SDK package licenses accepted.======] 100% Computing updates...

Why are the accepted licenses not acknowledged, and how do I resolve the Cordova error?