Android 采取 github 行动,一些许可尚未被接受

Android with github action some licences have not been accepted

我设置了以下 github 工作流程来构建 aab

name: upload-aab-to-play-console
on:
  push:
    branches:
      - main-kt-prod
jobs:
  build:
    runs-on: ubuntu-latest
    env:
      SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
    steps:
      - name: Checkout
        uses: actions/checkout@v2

      - name: set up JDK 1.8
        id: Setup_JDK
        uses: actions/setup-java@v1
        with:
          java-version: 11
  - name: build-with-gradle
    id: build
    run: |
      chmod +x gradlew
      ./gradlew build

但是我得到以下错误

FAILURE: Build failed with an exception.
Warning: License for package Android SDK Build-Tools 32-rc1 not accepted.
* What went wrong:
Could not determine the dependencies of task ':app:compileReleaseJavaWithJavac'.
> Failed to install the following Android SDK packages as some licences have not been accepted.
     build-tools;32.0.0-rc1 Android SDK Build-Tools 32-rc1
  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: /usr/local/lib/android/sdk

我试过这条线yes | ~/Android/Sdk/tools/bin/sdkmanager --licenses 来自 就在 ./gradlew build 之前,但我没有得到这样的文件或目录错误

在 gradle 构建步骤之前,您可能想要使用 setup-android 操作,因为它:

  • 下载 SDK 命令行工具
  • 接受 SDK 许可

你可以这样添加:

- name: Setup Android SDK
  uses: android-actions/setup-android@v2