Automatically accept all SDK licences

后端 未结 30 1769
感情败类
感情败类 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:22

    Unfortunately the way as OP originally solved it does not always work. If you find from the error message what is your builds current build-tools version. It could be that it is a higher version of build-tools that is missing. In that case you need to manually start SDK Manager and add the build-tools and accept license.

    Per OP instructions, it look as follows.

    $ ./gradlew build

     
    To honour the JVM settings for this build a new JVM will be forked. Please consider using the daemon: https://docs.gradle.org/2.14.1/userguide/gradle_daemon.html.
    
    FAILURE: Build failed with an exception.
    
    * What went wrong:
    A problem occurred configuring project ':app'.
    > You have not accepted the license agreements of the following SDK components:
      [Android SDK Build-Tools 24.0.2].
    
    ...
    BUILD FAILED
    

    NOTE: 2017-04-16

    The android tool has now been deprecated in favor of the new sdkmanager. Please see Joe Lawson's answer and subsequent posts from March (2017) and onward.

    Then adjust you command as follows:

    android update sdk --no-ui --filter build-tools-24.0.2,android-24,extra-android-m2repository
    
    Refresh Sources:
      Fetching https://dl.google.com/android/repository/addons_list-2.xml
      Validate XML
      Parse XML
      Fetched Add-ons List successfully
      Refresh Sources
      Fetching URL: https://dl.google.com/android/repository/repository-11.xml
      Validate XML: https://dl.google.com/android/repository/repository-11.xml
      Parse XML:    https://dl.google.com/android/repository/repository-11.xml
    ...
    Error: Ignoring unknown package filter 'build-tools-24.0.2'
    -------------------------------
    License id: android-sdk-license-xxxxxxxx
    Used by: 
     - SDK Platform Android 7.0, API 24, revision 2
      - Android Support Repository, revision 39
    -------------------------------
    
    ...
    
    November 20, 2015
    Do you accept the license 'android-sdk-license-xxxxxxxx' [y/n]: y
    
    Installing Archives:
      Preparing to install archives
      Downloading SDK Platform Android 7.0, API 24, revision 2
      Installing SDK Platform Android 7.0, API 24, revision 2
        Installed SDK Platform Android 7.0, API 24, revision 296%)
      Downloading Android Support Repository, revision 39
      Installing Android Support Repository, revision 39
        Installed Android Support Repository, revision 3999%)
      Done. 2 packages installed.
    

    Running this again, still do not make Gradle happy. So manual acceptance is the only solution until someone come up with something better. (Please do!)

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

    I finally found a solution on Windows, to have a real silent and automatic install:

    On Windows, the following syntax doesn't work:

    echo y | sdkmanager --licenses
    

    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

    call sdkmanager --licenses < file-y.txt
    

    This will create the needed files in the licenses directory. The problem is probably related to the use of BufferedReader in Java

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

    if you run yes | sdkmanager --licenses, then we print content of $ANDROID_HOME/licenses/android-sdk-license,

    we will get this

    # cat $ANDROID_HOME/licenses/android-sdk-license
    
    8933bad161af4178b1185d1a37fbf41ea5269c55
    
    d56f5187479451eabf01fb78af6dfcb131a6481e
    

    For GitLab CI, to accept Android SDK Build-Tools 26.0.2 licenses, you need to run this

    before_script:
      - mkdir -p $ANDROID_HOME/licenses
      - echo "8933bad161af4178b1185d1a37fbf41ea5269c55" > $ANDROID_HOME/licenses/android-sdk-license
      - echo "d56f5187479451eabf01fb78af6dfcb131a6481e" >> $ANDROID_HOME/licenses/android-sdk-license
    
    0 讨论(0)
  • 2020-11-22 17:28

    For the newest Android Studio (2.3) the best way to update/accept all licenses is to run:

    cd $ANDROID_HOME
    tools/bin/sdkmanager --licenses
    

    you might still need to copy the licence files to other locations based on your setup.

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

    this solved my error

    echo yes | $ANDROID_HOME/tools/bin/sdkmanager "build-tools;25.0.2"
    
    0 讨论(0)
  • 2020-11-22 17:29

    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

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