Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Github Actions error with Android Gradle plugin 8.2.0-alpha01 #7506

Closed
2 of 9 tasks
AndreSand opened this issue Apr 27, 2023 · 9 comments
Closed
2 of 9 tasks

Github Actions error with Android Gradle plugin 8.2.0-alpha01 #7506

AndreSand opened this issue Apr 27, 2023 · 9 comments

Comments

@AndreSand
Copy link

AndreSand commented Apr 27, 2023

Description

Hi, I updated to the latest Android Studio Hedgehog(canary) and updated gradle plugin 8.2.0-alpha01. When I run on Github Actions I get the below error.

Error:

Downloading https://services.gradle.org/distributions/gradle-8.0-bin.zip
...........10%............20%............30%............40%............50%............60%...........70%............[8](https://github.com/AndreSand/gmd-hello-world/actions/runs/4813251780/jobs/8569543450?pr=4#step:5:9)0%............[9](https://github.com/AndreSand/gmd-hello-world/actions/runs/4813251780/jobs/8569543450?pr=4#step:5:10)0%............[10](https://github.com/AndreSand/gmd-hello-world/actions/runs/4813251780/jobs/8569543450?pr=4#step:5:11)0%

Welcome to Gradle 8.0!

For more details see https://docs.gradle.org/8.0/release-notes.html

Starting a Gradle Daemon (subsequent builds will be faster)

Checking the license for package Android SDK Build-Tools 34-rc3 in /usr/local/lib/android/sdk/licenses
FAILURE: Build failed with an exception.

Warning: License for package Android SDK Build-Tools 34-rc3 not accepted.
* What went wrong:
Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
> Failed to install the following Android SDK packages as some licences have not been accepted.
     build-tools;34.0.0-rc3 Android SDK Build-Tools 34-rc3
  To build this project, accept the SDK license agreements and install the missing components using the Android Studio SDK Manager.
  All licenses can be accepted using the sdkmanager command line tool:
  sdkmanager.bat --licenses
  Or, to transfer the license agreements from one workstation to another, see https://developer.android.com/studio/intro/update.html#download-with-gradle
  
  Using Android SDK: /usr/local/lib/android/sdk

Platforms affected

  • Azure DevOps
  • GitHub Actions - Standard Runners
  • GitHub Actions - Larger Runners

Runner images affected

  • Ubuntu 20.04
  • Ubuntu 22.04
  • macOS 11
  • macOS 12
  • Windows Server 2019
  • Windows Server 2022

Image version and build link

Current runner version: '2.303.0'
Operating System:
Ubuntu 22.04.2
LTS
Runner Image:
Image: ubuntu-22.04

Is it regression?

Yes, it was working on previous gradle plugin versions

Expected behavior

New gradle releases builds Android successfully

Actual behavior

Currently GitHub image is not accepting the sdkmanager license.

Warning: License for package Android SDK Build-Tools 34-rc3 not accepted.

Repro steps

  1. Use an Android project
  2. Update to the latest gradle plugin version
  3. Build on GitHub Actions

Note: Only fails when we build using the latest Android gradle plugin version, Github Actions works fine using older Android gradle plugin versions.

@AndreSand AndreSand changed the title Github Actions error with android gradle plugin 8.2.0-alpha01 Github Actions error with Android Gradle plugin 8.2.0-alpha01 Apr 27, 2023
@ilia-shipitsin
Copy link
Contributor

I'm not sure about

      - name: Set up Gradle
        uses: gradle/gradle-build-action@v2

is 8.2.0 supposed to be supported by that action ?
maybe worth open an issue there as well

@ilia-shipitsin ilia-shipitsin self-assigned this Apr 28, 2023
@ilia-shipitsin
Copy link
Contributor

also Android SDK Build-Tools 34-rc3 is not yet officially released.
maybe it introduced some change in the way how license is accepted ?

@jesperancinha
Copy link

I came across this same problem.

@TWiStErRob
Copy link

I got the same, and not using Gradle Build Action, just plain gradlew.

Since AGP is requiring the new SDK build tools version, AGP must be compatible with that version.

I don't think it's the way the licenses are accepted. I have a feeling the images on GHA side were built before the version in question existed, and then the new licences couldn't have been accepted while building the image. GHA has a lot of Android version installed, so the licences for those must be already accepted and cached. Therefore I think the license for stable build tools and RC are probably different.

We will get stable Android 34 SDK tools in August-October this year, if Google follows the release cycle of past years. Could the pre-release SDK build tools version be added to GHA as pre-installed, similar to other versions? This would allow people to start using the latest AGP/Gradle combinations as soon as they want.

@sergei-pyshnoi
Copy link
Contributor

Hello @AndreSand . Its correct behavior when new installed version ask to accept license. The main reason why this worked on previous versions is that the sdk used were already pre-installed on the image. As workaround you can install and accept license Build-Tools 34-rc3 in runtime by adding echo "y" | /usr/local/lib/android/sdk/cmdline-tools/latest/bin/sdkmanager "build-tools;34.0.0-rc3" command to your workflow. I am closing this issue, but if you have additional question feel free to ask.

@TWiStErRob
Copy link

TWiStErRob commented May 4, 2023

I did a bit more digging: ${ANDROID_SDK_ROOT}/licenses/android-sdk-license is the only one pre-accepted in ubuntu-2204, but the RC build tools requires android-sdk-preview-license to be accepted, that's why @sergei-pyshnoi's solution will work.

Sources:

  • ls -la ${ANDROID_SDK_ROOT}/licenses
  • cat ${ANDROID_SDK_ROOT}/build-tools/33.0.2/package.xml
  • cat ${ANDROID_SDK_ROOT}/build-tools/34.0.0-rc3/package.xml (after installing it)

Note: cmdline-tools/latest is not installed by default, only cmdline-tools/9.0, I recommend applying android-actions/setup-android@v2 which makes Android build "just work" out of the box.

@jesperancinha
Copy link

jesperancinha commented May 6, 2023

I'm ignoring this version. An automated license acceptance makes little to no sense because it mentions that we need to accept the license as a kind of disclaimer for the effects of using an unstable alpha version. I truly appreciate the efforts but I personally prefer to test my projects with Beta, RC, or just a regular release version.

ParaskP7 added a commit to ParaskP7/sample-code-movies that referenced this issue Jun 18, 2023
This is done in order to overcome the below GitHub Actions CI failure
with later alpha '8.2.0' AGP versions:

------------------------------------------------------------------------
FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task
':android-test:extractDebugAnnotations'.
> Failed to install the following Android SDK packages as some licences
have not been accepted.
     build-tools;34.0.0-rc3 Android SDK Build-Tools 34-rc3
  To build this project, accept the SDK license agreements and install
  the missing components using the Android Studio SDK Manager.
  All licenses can be accepted using the sdkmanager command line tool:
  sdkmanager.bat --licenses
  Or, to transfer the license agreements from one workstation to
  another, see https://developer.android.com/studio/intro/update.html
  #download-with-gradle

  Using Android SDK: /usr/local/lib/android/sdk
------------------------------------------------------------------------

For more info see: Github Actions error with Android Gradle plugin
8.2.0-alpha01 #7506
- actions/runner-images#7506
@eygraber
Copy link

It would be super helpful if android-sdk-preview-license is accepted as part of the Ubuntu image (standard and large runner).

I'm maintaining tens of projects and it's a real drag to have to update all of their workflows to accept the licenses, and then remove those steps once the stable version is released. If Google sticks to their current strategy, this will be an issue every year.

Also, as @TWiStErRob mentioned cmdline-tools/latest should probably be installed as well.

@eygraber
Copy link

@TWiStErRob using the android-actions/setup-android@v2 action interacts very poorly with AGP Hedgehog. It makes builds 5-10x slower for some reason (I'm assuming because it is applying a lot of out of date tools).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants