failed to install the following android sdk packages as some licences have not been accepted. mac code example

Example 1: Failed to install the following Android SDK packages as some licences have not been accepted.

# macos:
export JAVA_HOME=/Applications/Android\ Studio.app/Contents/jre/jdk/Contents/Home
yes | ~/Library/Android/sdk/tools/bin/sdkmanager --licenses

# windows:
%ANDROID_HOME%/tools/bin/sdkmanager --licenses

# GNU/Linux Distributions:
yes | ~/Android/Sdk/tools/bin/sdkmanager --licenses

Example 2: Failed to install the following Android SDK packages as some licences have not been accepted.

> flutter doctor --android-licenses

Example 3: Failed to install the following Android SDK packages as some licences have not been accepted. build-tools;28.0.3 Android SDK Build-Tools 28.0.3 platforms;android-29 Android SDK Platform 29

%ANDROID_HOME%/tools/bin/sdkmanager --licenses

Example 4: Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'. > Failed to install the following Android SDK packages as some licences have not been accepted.

flutter doctor --android-licenses