CircleCI构建Android SDK升级

最近在适配Android8,把targetSdkVersion升级到27以支持android8.1了

ext {
    // Sdk and tools
    minSdkVersion = 16
    targetSdkVersion = 27
    compileSdkVersion = 27

    // App dependencies
    supportLibraryVersion = '27.1.1'
}

适配完后的一段时间内没发现什么问题,后来在CircleCI构建发布时,出现了错误

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':app'.
> Failed to install the following Android SDK packages as some licences have not been accepted.
     platforms;android-27 Android SDK Platform 27
  To build this project, accept the SDK license agreements and install the missing components using the Android Studio SDK Manager.
  Alternatively, to transfer the license agreements from one workstation to another, see http://d.android.com/r/studio-ui/export-licenses.html
  
  Using Android SDK: /opt/android/sdk

好像是没有安装android-27的sdk,安装协议也没有同意。一开始对CircleCI的工作流程和配置也不是很熟悉,所以鼓捣了半天。但最终还是解决了,要升级CircleCI中的andoird版本,需要修改两个配置文件

  1. .travis.yml 升级构建工具版本,android sdk版本以及同意协议
language: android
android:
  components:
  - tools
  - build-tools-27.0.2
  - extra-android-support
  - extra-google-m2repository
  - extra-android-m2repository
licenses:
- 'android-sdk-license-.+'

before_install:
- yes | sdkmanager "platforms;android-27"
  1. .circleci/config.yml 主要是升级ci主机中使用的docker镜像,镜像中部署的是android-27的编译环境
docker:
      - image: circleci/android:api-27-alpha

你可能感兴趣的:(CircleCI构建Android SDK升级)