From fe11ce91ac2f5b8f068ed70d5773081e723f7403 Mon Sep 17 00:00:00 2001 From: Guillermo Mazzola Date: Fri, 20 Oct 2023 15:32:54 +0200 Subject: [PATCH] Added Android SDK setup --- .github/workflows/setup-host/action.yml | 18 ++++++++++++++++++ demo-project/ui-tests/build.gradle.kts | 12 ++++++++++++ 2 files changed, 30 insertions(+) diff --git a/.github/workflows/setup-host/action.yml b/.github/workflows/setup-host/action.yml index 3ab3b2a..038ac9f 100644 --- a/.github/workflows/setup-host/action.yml +++ b/.github/workflows/setup-host/action.yml @@ -11,3 +11,21 @@ runs: java-version: '17' - name: Setup Gradle uses: gradle/gradle-build-action@v2 + - name: Setup `ANDROID_HOME` environment variable + shell: bash + run: echo ANDROID_HOME=~/android/sdk >> $GITHUB_ENV + - name: Cache Android SDK + uses: actions/cache@v3 + with: + key: ${{ runner.os }}/${{ runner.arch }}-android-sdk + path: ${{ env.ANDROID_HOME }} + - name: Setup host for Android Emulator + shell: bash + run: | + # https://developer.android.com/studio/test/gradle-m./granaged-devices#create_a_gradle_managed_device + echo "android.testoptions.manageddevices.emulator.gpu=swiftshader_indirect" >> ~/.gradle/gradle.properties + + # https://github.blog/changelog/2023-02-23-hardware-accelerated-android-virtualization-on-actions-windows-and-linux-larger-hosted-runners/ + echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules + sudo udevadm control --reload-rules + sudo udevadm trigger --name-match=kvm diff --git a/demo-project/ui-tests/build.gradle.kts b/demo-project/ui-tests/build.gradle.kts index 0f290e2..169023c 100644 --- a/demo-project/ui-tests/build.gradle.kts +++ b/demo-project/ui-tests/build.gradle.kts @@ -48,3 +48,15 @@ dependencies { implementation(libs.androidx.test.junit) implementation(libs.androidx.test.espresso) } + +val acceptAndroidLicences by tasks.registering(Exec::class) { + val androidHome = androidComponents.sdkComponents.sdkDirectory.get().asFile.absolutePath + + commandLine("bash", "-c", "yes | $androidHome/cmdline-tools/latest/bin/sdkmanager --licenses") +} + +afterEvaluate { + tasks.named("${pixel2.name}Setup") { + dependsOn(acceptAndroidLicences) + } +}