代码之家  ›  专栏  ›  技术社区  ›  Ivan Rudnev

Travis CI Android SDK许可证问题

  •  5
  • Ivan Rudnev  · 技术社区  · 8 年前

    我正试图用Travis构建我的Android项目,目前我遇到了错误:

    A problem occurred configuring project ':app'.
    > You have not accepted the license agreements of the following SDK 
    components:
    [Android SDK Build-Tools 27.0.1].
    

    我不知道怎么做,但昨天我可以解决这个问题:

    before_install:
        - yes | sdkmanager "platforms;android-27"
    

    但现在这对我没有帮助。如有任何建议,我将不胜感激。

    这里是构建URL https://travis-ci.org/madsunrise/luna-mobile/jobs/325034903 我还放了特拉维斯。yml以下

    sudo: required
    
    language: android
    jdk: oraclejdk8
    
    notifications:
      email:
        recipients:
          - rudnev.vanya@gmail.com
        on_success: change
        on_failure: always
    
    before_cache:
      - rm -f  $HOME/.gradle/caches/modules-2/modules-2.lock
      - rm -rf $HOME/.gradle/caches/*/plugin-resolution/
    
    before_install:
      - yes | sdkmanager "platforms;android-27"
    
    cache:
      directories:
      - $HOME/.gradle/caches/
      - $HOME/.gradle/wrapper/
      - $HOME/.android/build-cache
    
    env:
     global:
     - ANDROID_API=27
     - ANDROID_BUILD_TOOLS=27.0.2
    
    android:
     components:
      - tools
      - tools # Running this twice get's the latest build tools
      - platform-tools
      - android-${ANDROID_API}
      - build-tools-${ANDROID_BUILD_TOOLS}
      - extra
    
    script:
       - ./gradlew clean test build
    
    1 回复  |  直到 8 年前
        1
  •  8
  •   albodelu    8 年前

    代替

    - ANDROID_BUILD_TOOLS=27.0.2
    

    通过

    - ANDROID_BUILD_TOOLS=27.0.1
    

    或添加:

    - echo yes | sdkmanager "build-tools;27.0.1"
    

    要显式安装匹配的版本并按注释接受许可证 here.

    解释

    自从 Android Plugin for Gradle 3.0.0 (October 2017)

    您不再需要为构建工具指定插件的版本 默认情况下,使用所需的最低版本。因此,您现在可以删除 android。buildToolsVersion属性。

    您没有指定版本 here ,您正在显式安装版本27.0.2,Gradle正在下载版本27.0.1,但未接受许可协议,如前所述 here .

    或者添加 buildToolsVersion 27.0.2 到您的 app/build.gradle :

    android {
        compileSdkVersion 27
        buildToolsVersion "27.0.2"
    

    笔记

    似乎可以自动接受所有许可证 echo 不再需要:

    - yes | sudo sdkmanager --licenses
    

    但我没有测试,请检查 this question 了解更多信息。

    您可能仍需要将许可证文件复制到其他位置 根据您的设置。