Automatically accept all SDK licences

后端 未结 30 1779
感情败类
感情败类 2020-11-22 16:35

Since gradle android plugins 2.2-alpha4:

Gradle will attempt to download missing SDK packages that a project depends on

Which

相关标签:
30条回答
  • 2020-11-22 17:35

    I have encountered this with the alpha5 preview.

    Jake Wharton pointed out to me that you can currently use

    mkdir -p "$ANDROID_SDK/licenses"
    echo -e "\n8933bad161af4178b1185d1a37fbf41ea5269c55" > "$ANDROID_SDK/licenses/android-sdk-license"
    echo -e "\n84831b9409646a918e30573bab4c9c91346d8abd" > "$ANDROID_SDK/licenses/android-sdk-preview-license"
    

    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 :)

    And install it manually, but it is the gradle's new feature purpose to do it.

    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

    SDK auto-download: Gradle will attempt to download missing SDK packages that a project depends on.

    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...

    0 讨论(0)
  • 2020-11-22 17:35

    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

    0 讨论(0)
  • 2020-11-22 17:36

    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.

    0 讨论(0)
  • 2020-11-22 17:37

    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.

    0 讨论(0)
  • 2020-11-22 17:38

    You can also just execute:

    $ANDROID_HOME/tools/bin/sdkmanager --licenses
    

    And in Windows, execute:

    %ANDROID_HOME%/tools/bin/sdkmanager --licenses
    
    0 讨论(0)
  • 2020-11-22 17:40

    We found same issue building the project on Jenkins. With buildToolsVersion '25.0.2', we must accept licenses before building. In our case, we needed to run:

    yes | sdkmanager --update that accepts licenses for the sdkmanager itself, and then

    yes | sdkmanager --licenses that accepts new licenses not previously accepted

    Remember: run these commans with the same user that jenkins does. In our Debian, the Jenkins user is just jenkins. In other words: doing it as root will create the accepted licenses as root, so Jenkins will not read them.

    By the way, we found sdkmanager at /var/lib/jenkins/tools/android-sdk/tools/bin. If yours is not there, find it with find / -name "sdkmanager"

    0 讨论(0)
提交回复
热议问题