androidgithub-actionsworkflow

Where to setup Android SDK in a typical Github Actions workflow?


Here is a normal test_and_apk job in Build workflow of nowinandroid repo.

jobs:
  test_and_apk:
    name: "Local tests and APKs"
    runs-on: ubuntu-latest

    permissions:
      contents: write
      pull-requests: write
      security-events: write

    timeout-minutes: 60

    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Copy CI gradle.properties
        run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties

      - name: Set up JDK 17
        uses: actions/setup-java@v4
        with:
          distribution: 'zulu'
          java-version: 17

      - name: Setup Gradle
        uses: gradle/actions/setup-gradle@v4
        with:
          cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}

      - name: Run local tests
        run: ./gradlew testDemoDebug

      - name: Build all build type and flavor permutations
        run: ./gradlew :app:assemble

I'm so surprised there is no place to call android-actions/setup-android@v3. But finally it's able to run test and build the Android app.

Does it mean the ubuntu-latest contains the Android SDK already? Or gradle/actions/setup-gradle also download Android SDK (uhm, I don't think so). Can anyone explain it to me?


Solution

  • Android SDK is included in the VM image (in your case ubuntu-latest) and the SDK path is set by ANDROID_HOME as an environment variable.

    You can see all the preinstalled software and environment variable here