Since gradle android plugins 2.2-alpha4:
Gradle will attempt to download missing SDK packages that a project depends on
Which
The android
tool is deprecated and you should use the sdkmanager
instead. sdkmanager
also writes the licenses file when you first accept it. The license changes depending on which SDK you are using so even though the command
echo -e "\n8933bad161af4178b1185d1a37fbf41ea5269c55" > "$ANDROID_SDK/licenses/android-sdk-license"
works on some systems. It won't work on all. Some SDK installs expect to license file to end without a newline in the file so try adding a -n
to the echo command.
echo -n -e "\n8933bad161af4178b1185d1a37fbf41ea5269c55" > "$ANDROID_SDK/licenses/android-sdk-license"
If that isn't working you can try using the base64 encoding instead.
So to discover my license:
$> rm ${ANDROID_HOME}/
$> unzip tools_r25.2.3-linux.zip -d ${ANDROID_HOME}
$> ${ANDROID_HOME}/tools/bin/sdkmanager "system-images;android-23;default;x86_64"
It'll prompt you to accept the license. After accepting it'll copy it to ${ANDROID_HOME}/licenses/android-sdk-license
. To ensure you always get exactly what is written use base64
.
$> base64 ${ANDROID_HOME}/licenses/android-sdk-license
Cjg5MzNiYWQxNjFhZjQxNzhiMTE4NWQxYTM3ZmJmNDFlYTUyNjljNTU=
Then you can use base64 -d
recreate the file exactly.
$> echo Cjg5MzNiYWQxNjFhZjQxNzhiMTE4NWQxYTM3ZmJmNDFlYTUyNjljNTU= | base64 -d > ${ANDROID_HOME}/licenses/android-sdk-license
You can verify if the file written is what is expected by running a sha1sum on it.
$> sha1sum ${ANDROID_HOME}/licenses/android-sdk-license
da6b80c9c47b41c0bf7032938e7137a58a3dc249