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 ?
Thanks!
[EDIT]
A solution was to execute:
android update sdk --no-ui --filter build-tools-24.0.0,android-24,extra-android-m2repository
And install it manually, but it is the gradle's new feature purpose to do it.
[EDIT 2]
A better solution is to use the sdkmananger:
yes | sudo sdkmanager --licenses
You can also just execute
$ANDROID_HOME/tools/bin/sdkmanager --licenses
Or for Windows execute
%ANDROID_HOME%/tools/bin/sdkmanager --licenses
I had the same error while using Cordova.
The problem was due to the fact that I installed Android Sdk through Android Studio and through
apt
withapt install android-sdk adb
. And Cordova was calling the files installed throughapt
instead of the files in my home directory.It worked once I changed the path to SDK in bash:
Then I removed the system files that weren't used anymore:
apt remove android-sdk adb
.For the new
sdkmanager
utility:yes | $ANDROID_HOME/tools/bin/sdkmanager "build-tools;24.0.3"
There's a bit of a delay between yesses, so the command could hang with the license showing for a while, but it doesn't require human intervention.
Copy the entire licenses/ directory and paste it into the Android SDK home directory on the machine where you wish to build your projects.
https://developer.android.com/studio/intro/update.html#download-with-gradle
this resolved the issue for me
On Mac OSX, navigate to the
sdk/tools/bin
Then run
./sdkmanager --licenses
, and accept all the licenses.FOR REACT NATIVE APPs:
If you are having this problem for a React Native app, in addition to above mentioned steps, make sure you have the local.properties file in the android directory(AppName/android) of your app which points to your 'sdk' directory: