Skip to content

Instantly share code, notes, and snippets.

@doppelganger9
Last active November 9, 2021 19:36
Show Gist options
  • Save doppelganger9/fe3aca0765607b9a5881ea29a75da361 to your computer and use it in GitHub Desktop.
Save doppelganger9/fe3aca0765607b9a5881ea29a75da361 to your computer and use it in GitHub Desktop.
This script adds android licenses hash to be able to update/install sdk package on the command line (android / sdkmanager tools) without having to manually input 'y' to accept the license terms. Credits to http://stackoverflow.com/a/38381577/526660
#!/usr/bin/env bash
#
# This script adds android licenses hash to be able to update/install sdk package on the
# command line (android / sdkmanager tools) without having to manually input 'y' to accept the
# license terms.
#
# Prerequisite: ANDROID_HOME env var must be set.
#
# Tested on MacOS 10.12.3
#
if [ -f ${ANDROID_HOME}/licenses/android-sdk-license ]; then
echo "Android SDK License file already exists : ${ANDROID_HOME}/licenses/android-sdk-license"
else
echo "Android SDK License file will be created : ${ANDROID_HOME}/licenses/android-sdk-preview-license"
echo "echo -e \"\n8933bad161af4178b1185d1a37fbf41ea5269c55\" > \"${ANDROID_HOME}/licenses/android-sdk-license\""
echo -e "\n8933bad161af4178b1185d1a37fbf41ea5269c55" > "${ANDROID_HOME}/licenses/android-sdk-license"
if [ $? -ne 0 ]; then
echo "interrupted : creating android sdk license file error"
exit -1
fi
fi
if [ -f ${ANDROID_HOME}/licenses/android-sdk-preview-license ]; then
echo "Android Preview SDK License file already exists : ${ANDROID_HOME}/licenses/android-sdk-preview-license"
else
echo "Android Preview SDK License file will be created : ${ANDROID_HOME}/licenses/android-sdk-preview-license"
echo "echo -e \"\n84831b9409646a918e30573bab4c9c91346d8abd\" > \"${ANDROID_HOME}/licenses/android-sdk-preview-license\""
echo -e "\n84831b9409646a918e30573bab4c9c91346d8abd" > "${ANDROID_HOME}/licenses/android-sdk-preview-license"
if [ $? -ne 0 ]; then
echo "interrupted : creating android sdk preview license file error"
exit -2
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment