Since gradle android plugins 2.2-alpha4:
Gradle will attempt to download missing SDK packages that a project depends on
Which is amazingly cool and was know to be a JakeWharton project.
But, to download the SDK library you need to: accept the license agreements or gradle tells you:
You have not accepted the license agreements of the following SDK components: [Android SDK Build-Tools 24, Android SDK Platform 24]. 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
And this is a problem because I would love to install all sdk dependencies while doing a gradle build
.
I am looking for a solution to automatically accept all licenses. Maybe a gradle script ? Do you have any ideas ?
Some SDK installs expect to license file to end without a newline in the file so try adding a -n to the echo command. If that isn't working you can try using the base64 encoding instead. It'll prompt you to accept the license. After accepting it'll copy it to ${ANDROID_HOME}/licenses/android-sdk-license .
UPDATE 2021 This should be the accepted answer as its easy and upto date
AndroidSDK can finally accept licenses.
Go to Android\sdk\tools\bin
yes | sdkmanager --licenses
EDIT:
as pointed out in the comments by @MoOx, on macOS, you can do
yes | sudo ~/Library/Android/sdk/tools/bin/sdkmanager --licenses
as pointed out in the comments by @pho, @mikebridge and @ Noitidart on Windows, you can do
cmd.exe /C"%ANDROID_HOME%\tools\bin\sdkmanager.bat --licenses"
be sure to install java before
I was getting this error:
License for package Android SDK Build-Tools 30.0.2 not accepted.
So, I went to Tools -> SDK Manager -> SDK Tools. Then I installed Google Play Licensing Library. It solved the problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With