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 accept all the license by executing the following command:
This will prompt you through each licenses you haven't accepted yet and you can just enter
y
to accept each of them.I have encountered this with the
alpha5
preview.Jake Wharton pointed out to me that you can currently use
to recreate the current
$ANDROID_HOME/license
folder on you machine. This would have the same result as the process outlined in the link of the error msg (http://tools.android.com/tech-docs/new-build-system/license).The hashes are sha1s of the licence text, which I imagine will be periodically updated, so this code will only work for so long :)
I was surprised at first that this didnt work out of the box, even when I had accepted the licenses for the named components via the
android
tool, but it was pointed out to me its the SDK manager inside AS that creates the/licenses
folder.I guess that official tools would not want to skip this step for legal reasons.
Rereading the release notes it states
Which does not mean it will work if you have not installed the android tools yet and have already accepted the latest license(s).
EDIT: Saying that, it still does not work on my test gubuntu box until I link the SDK up to AS. CI works fine though - not sure what the difference is...
I solved this problem by creating a public git repo with the accepted license files. Then I use
wget
to fetch these licenses on any machine I need into a [sdk-dir]/licenses directory before running ./gradlew to build my project.Finally, this 2 simple steps worked for me on windows 10.
1) Make sure you update your android build tools and api. On your Android Sdk Just click on install packages to install available updates.
2) Start your Android Studio and you'll be prompted to install the reqiured build tools for the already updated api and tools, This will install the build tools properties including the licences and your done.
For an error message about SDK api number 25:
android update sdk --no-ui --all --filter build-tools-25.0.1,android-25,extra-android-m2repository
I finally found a solution on Windows, to have a real silent and automatic install:
On Windows, the following syntax doesn't work:
It seems the "y" aren't correctly sent to the java program called in the batch.
The workaround is to create a file file-y.txt with several "y", one by line, and to use
This will create the needed files in the licenses directory. The problem is probably related to the use of BufferedReader in Java