Automatically accept all SDK licences

后端 未结 30 1819
感情败类
感情败类 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!)

提交回复
热议问题