CircleCI上でlicences have not been acceptedに対応する
CircleCI上で Failed to install the following Android SDK packages as some licences have not been accepted.
のエラーでBuildが失敗する時の対応についてもメモ。他にもいろんな方法があるっぽい…が一例として。
特にCI上で使用しているdocker imageはcircleci/android:api-28-node8-alpha
の場合。
現象
./gradlew assembleDebug
する時等に以下のエラーでjobが失敗する。
> Failed to install the following Android SDK packages as some licences have not been accepted. build-tools;28.0.2 Android SDK Build-Tools 28.0.2 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
解決策
以下のファイルを作成し、assembleDebug
タスクの前に実行する。
#!/bin/bash yes | /opt/android/sdk/tools/bin/sdkmanager "build-tools;28.0.2”
(sdkmanagerのパスは調べる必要があります)
プロセス
他のAndroidプロジェクトで circleci/android:api-23-alpha
を使っていた時も同じエラーでCIが突然failedするようになったが circleci/android:api-28-alpha
新しいものを使うことによって解決された。 ref
今回使っていた circleci/android:api-28-node8-alpha
ではまだ対応されていなかったので、build-tool 28.0.2のインストール時になんらかの方法でライセンス同意しなければいけなかった。
https://discuss.circleci.com/t/licences-for-android-build-tools-not-accepted/17285/27
この記事にある方法を試したが、expect
コマンドがCIの環境に入っていなかったので代替できる yes
コマンドで同じ挙動を実現できた。
[追記]
他のAndroidプロジェクトで
circleci/android:api-23-alpha
を使っていた時も同じエラーでCIが突然failedするようになったがcircleci/android:api-28-alpha
新しいものを使うことによって
ここの部分についてはcircleci/android:api-28
でも動作することを確認。-alpha
がついているものは最新のupdateが降ってこないので、-alpha
なしのdocker imageが存在する場合はそちらを使った方がよさそう。( circleci/android:api-28-node8-alpha
に関しては2019/1/31時点では-alpha
なしversionのものはなかった)