Automatically accept all SDK licences

2019-01-01 06:01发布

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

30条回答
冷夜・残月
2楼-- · 2019-01-01 06:40

I run

#react-native run-android 

from terminal and met that problem. For manually, go to Android Studio -> Android SDK -> SDK Platform Click Show Packages Detail and check :

+ Google APIs
+ Android SDK Platform 23
+ Intel x86 Atom_64 System Image
+ Google APIs Intel x86 Atom_64 System Image

When install packages, check accept license => can solve the problem.

查看更多
妖精总统
3楼-- · 2019-01-01 06:41

this solved my error

echo yes | $ANDROID_HOME/tools/bin/sdkmanager "build-tools;25.0.2"
查看更多
泛滥B
4楼-- · 2019-01-01 06:41

Ok FOR ANYONE HAVING THIS ISSUE AS OF 2018. The above answers did NOT work for me at all. What DID work was opening Android SDK - clicking the DOWNLOAD button on the tool bar and selecting the appropriate packages. After they finish downloading, it will let you accept the license agreement.

enter image description here

查看更多
荒废的爱情
5楼-- · 2019-01-01 06:44

Note that for anyone coming to this question currently, build-tools-24.0.2 is (I think) now considered obsolete, so you'll get:

 Error: Ignoring unknown package filter 'build-tools-24.0.2'

when running the various commands that have been suggested to install them.

The solution is to add --all:

android update sdk --no-ui --all --filter "build-tools-24.0.2"

Also if you're on 32bit linux, everything after build tools 23.0.1 is 64bit only, so will not run. 32bit users are stuck on 23.0.1, the only way to get a later build tools is to switch to 64bit.

查看更多
旧时光的记忆
6楼-- · 2019-01-01 06:44

In Windows PowerShell, you can do

for($i=0;$i -lt 30;$i++) { $response += "y`n"}; $response | sdkmanager --licenses

This is much more flexible and requires zero manual intervention. The 30 number is arbitrary, should be enough to cover the number of license acceptances, but can be increased if needed

查看更多
只靠听说
7楼-- · 2019-01-01 06:46

AndroidSDK can finally accept licenses.

yes | sdkmanager --licenses
查看更多
登录 后发表回答