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

Regression in OSX virtual environment 20210718.2 : Android Studio build tools appear to be corrupted #3757

Closed
1 of 7 tasks
shankari opened this issue Jul 19, 2021 · 38 comments
Assignees
Labels
Area: Android Area: Image administration investigate Collect additional information, like space on disk, other tool incompatibilities etc. OS: macOS

Comments

@shankari
Copy link

shankari commented Jul 19, 2021

Description

Building an ionic/cordova project using Github actions fails, although it was passing two days ago.
The build logs say:

> Installed Build Tools revision 31.0.0 is corrupted. Remove and install again using the SDK Manager.

There have been no changes to the native code in the past two days.

Virtual environments affected

  • Ubuntu 16.04
  • Ubuntu 18.04
  • Ubuntu 20.04
  • macOS 10.15
  • macOS 11
  • Windows Server 2016
  • Windows Server 2019

Image version and build link

Current runner version: '2.278.0'
Operating System
Virtual Environment
  Environment: macos-10.15
  Version: 20210718.2
  Included Software: https://github.com/actions/virtual-environments/blob/macOS-10.15/20210718.2/images/macos/macos-10.15-Readme.md
  Image Release: https://github.com/actions/virtual-environments/releases/tag/macOS-10.15%2F20210718.2

https://github.com/e-mission/e-mission-phone/runs/3109100824?check_suite_focus=true

Is it regression?

https://github.com/e-mission/e-mission-phone/runs/3094799247?check_suite_focus=true

Expected behavior

The build would be successful, as it was in version 20210712.4, two days ago (https://github.com/e-mission/e-mission-phone/runs/3094799247?check_suite_focus=true)

Current runner version: '2.278.0'
Operating System
Virtual Environment
  Environment: macos-10.15
  Version: 20210712.4
  Included Software: https://github.com/actions/virtual-environments/blob/macOS-10.15/20210712.4/images/macos/macos-10.15-Readme.md
  Image Release: https://github.com/actions/virtual-environments/releases/tag/macOS-10.15%2F20210712.4

Actual behavior

The build is failing in version 20210718.2, today (https://github.com/e-mission/e-mission-phone/actions/runs/1046721329) although there have been no changes to the android code.

Repro steps

  1. Run the workflow from https://github.com/e-mission/e-mission-phone/actions/workflows/android-build.yml on version 20210712.4: it passes
  2. Run the workflow from https://github.com/e-mission/e-mission-phone/actions/workflows/android-build.yml on 20210718.2: it fails
@shankari shankari changed the title Android Studio build tools appear to be corrupted Regression in OSX virtual environment 20210718.2 : Android Studio build tools appear to be corrupted Jul 20, 2021
@al-cheb al-cheb added Area: Android Area: Image administration OS: macOS investigate Collect additional information, like space on disk, other tool incompatibilities etc. and removed needs triage labels Jul 20, 2021
@al-cheb
Copy link
Contributor

al-cheb commented Jul 20, 2021

Hi, @shankari
It's not the regression. To mitigate the issue you should manually set put build-tools version to the previous version = 30 or upgrade to Android Gradle Plugin 7.0+:

  1. https://stackoverflow.com/questions/68387270/android-studio-error-installed-build-tools-revision-31-0-0-is-corrupted
  2. https://exerror.com/installed-build-tools-revision-31-0-0-is-corrupted-remove-and-install-again-using-the-sdk-manager/

@shankari
Copy link
Author

shankari commented Jul 20, 2021

@al-cheb

From the first SO link that you provided, SDK tools 31 is in fact corrupted and we need to wait for a patch from Google.

Screen Shot 2021-07-20 at 12 03 25 AM

Either downgrading to v30.0 ("uncheck "Show Package Details" and then you can select a lower version.") or "upgrade to Android Gradle Plugin 7.0" seems to require modifying the Android Studio install.

But I'm not installing android studio manually - I'm using the pre-installed Android Studio in the virtual environment.

In https://github.com/actions/virtual-environments/blob/macOS-10.15/20210712.4/images/macos/macos-10.15-Readme.md (working), the list of installed build tools is

Android SDK Build-tools | 30.0.0 30.0.1 30.0.2 30.0.329.0.0 29.0.1 ...

In https://github.com/actions/virtual-environments/blob/macOS-10.15/20210718.2/images/macos/macos-10.15-Readme.md (not working), the list of installed build tools is

Android SDK Build-tools | 31.0.0 30.0.0 30.0.1 30.0.2 30.0.329.0.0 29.0.1 ...

So basically, the newer image added SDK build-tools = 31, which is corrupted and breaks android studio.

Are you expecting every developer to write a task to downgrade the build tools using the sdk manager from the command line? Seems like it would be much easier to fix the image once and for all.

@miketimofeev
Copy link
Contributor

@shankari we are sorry to hear that you're experiencing issues, but it looks like the dx removal is by design and all the following build-tools won't have dx as well:
https://android-developers.googleblog.com/2020/02/the-path-to-dx-deprecation.html
We suggest you stick to the build-tools < 31 or create a symlink from d8 to dx as it also solves the issue.

@nokiadingding
Copy link

From the readme.md, it seems like it's missing Android SDK Tools. The following is from 20210626.1 (https://github.com/actions/virtual-environments/blob/macOS-10.15/20210626.1/images/macos/macos-10.15-Readme.md#android)

image

This issue is blocking us from build Android. We are using Microsoft DevOps so we can't do anything.
`Execution failed for task ':transformClassesWithMultidexlistForRelease'.

dx.jar is missing
`

@miketimofeev
Copy link
Contributor

miketimofeev commented Jul 20, 2021

@nokiadingding SDK tools are in place in $ANDROID_HOME/tools, just not mentioned in the readme as they are deprecated in favor of command-line tools.
Please consider one of the following options:

  • Upgrade your project to use d8 compiler as dx is deprecated by google
  • Stick to build-tools 30.0.3 or earlier, which is also exist on the image
  • Create a symlink from d8 to dx:
ln -s ${ANDROID_HOME}/build-tools/31.0.0/d8 ${ANDROID_HOME}/build-tools/31.0.0/dx
  • Remove build-tools 31
SDKMANAGER=$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager
echo y | $SDKMANAGER --uninstall "build-tools;31.0.0"

@luissilvaos
Copy link

Stick to build-tools 30.0.3 or earlier, which is also exist on the image

Even with that version builds are failing with the mentioned error.

@miketimofeev
Copy link
Contributor

@luissilvaos could you please provide the full log of failed build with 30.0.3?

@luissilvaos
Copy link

Here is @miketimofeev
My project uses build-tools 30.0.3 but I'm only getting error messages related with 31.0.0

2021-07-20T09:33:32.6708910Z [command]/Users/runner/work/1/s/tests/android/sample-app-tests/gradlew clean testDebugUnitTest connectedDebugAndroidTest
2021-07-20T09:33:33.6503620Z Downloading https://services.gradle.org/distributions/gradle-6.5-all.zip
2021-07-20T09:33:39.7080550Z ........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
2021-07-20T09:33:39.7103340Z Unzipping /Users/runner/.gradle/wrapper/dists/gradle-6.5-all/2oz4ud9k3tuxjg84bbf55q0tn/gradle-6.5-all.zip to /Users/runner/.gradle/wrapper/dists/gradle-6.5-all/2oz4ud9k3tuxjg84bbf55q0tn
2021-07-20T09:33:49.4610380Z Set executable permissions for: /Users/runner/.gradle/wrapper/dists/gradle-6.5-all/2oz4ud9k3tuxjg84bbf55q0tn/gradle-6.5/bin/gradle
2021-07-20T09:33:50.3170440Z 
2021-07-20T09:33:50.3227370Z Welcome to Gradle 6.5!
2021-07-20T09:33:50.3328690Z 
2021-07-20T09:33:50.3330010Z Here are the highlights of this release:
2021-07-20T09:33:50.3432230Z  - Experimental file-system watching
2021-07-20T09:33:50.3499740Z  - Improved version ordering
2021-07-20T09:33:50.3512760Z  - New samples
2021-07-20T09:33:50.3515620Z 
2021-07-20T09:33:50.3526050Z For more details see https://docs.gradle.org/6.5/release-notes.html
2021-07-20T09:33:50.3529080Z 
2021-07-20T09:33:50.5608400Z Starting a Gradle Daemon (subsequent builds will be faster)
2021-07-20T09:34:21.5565700Z Observed package id 'ndk;21.4.7075529' in inconsistent location '/Users/runner/Library/Android/sdk/ndk-bundle' (Expected '/Users/runner/Library/Android/sdk/ndk/21.4.7075529')
2021-07-20T09:34:21.7547400Z Build-tool 31.0.0 is missing DX at /Users/runner/Library/Android/sdk/build-tools/31.0.0/dx
2021-07-20T09:34:21.9519800Z Observed package id 'ndk;21.4.7075529' in inconsistent location '/Users/runner/Library/Android/sdk/ndk-bundle' (Expected '/Users/runner/Library/Android/sdk/ndk/21.4.7075529')
2021-07-20T09:34:22.2023610Z File /Users/runner/.android/repositories.cfg could not be loaded.
2021-07-20T09:34:23.1027090Z Observed package id 'ndk;21.4.7075529' in inconsistent location '/Users/runner/Library/Android/sdk/ndk-bundle' (Expected '/Users/runner/Library/Android/sdk/ndk/21.4.7075529')
2021-07-20T09:34:23.1129950Z Build-tool 31.0.0 is missing DX at /Users/runner/Library/Android/sdk/build-tools/31.0.0/dx
2021-07-20T09:34:23.1228830Z 
2021-07-20T09:34:23.1330630Z FAILURE: Build failed with an exception.
2021-07-20T09:34:23.1431680Z 
2021-07-20T09:34:23.1532590Z * What went wrong:
2021-07-20T09:34:23.1628010Z Could not determine the dependencies of task ':CordovaLib:compileDebugAidl'.
2021-07-20T09:34:23.1645170Z > Failed to query the value of task ':CordovaLib:compileDebugAidl' property 'aidlFrameworkProvider'.
2021-07-20T09:34:23.1651820Z    > Installed Build Tools revision 31.0.0 is corrupted. Remove and install again using the SDK Manager.
2021-07-20T09:34:23.1753190Z 
2021-07-20T09:34:23.1770470Z * Try:
2021-07-20T09:34:23.1872880Z Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
2021-07-20T09:34:23.1954650Z 
2021-07-20T09:34:23.2120280Z * Get more help at https://help.gradle.org
2021-07-20T09:34:23.2221280Z 
2021-07-20T09:34:23.2315440Z BUILD FAILED in 49s
2021-07-20T09:34:24.3093870Z Error: The process '/Users/runner/work/1/s/tests/android/sample-app-tests/gradlew' failed with exit code 1
2021-07-20T09:34:24.3195410Z     at ExecState._setResult (/Users/runner/work/_tasks/Gradle_8d8eebd8-2b94-4c97-85af-839254cc6da4/2.186.0/node_modules/azure-pipelines-task-lib/toolrunner.js:937:25)
2021-07-20T09:34:24.3219900Z     at ExecState.CheckComplete (/Users/runner/work/_tasks/Gradle_8d8eebd8-2b94-4c97-85af-839254cc6da4/2.186.0/node_modules/azure-pipelines-task-lib/toolrunner.js:920:18)
2021-07-20T09:34:24.3235040Z     at ChildProcess.<anonymous> (/Users/runner/work/_tasks/Gradle_8d8eebd8-2b94-4c97-85af-839254cc6da4/2.186.0/node_modules/azure-pipelines-task-lib/toolrunner.js:833:19)
2021-07-20T09:34:24.3253470Z     at ChildProcess.emit (events.js:198:13)
2021-07-20T09:34:24.3273110Z     at maybeClose (internal/child_process.js:982:16)
2021-07-20T09:34:24.3292910Z     at Socket.stream.socket.on (internal/child_process.js:389:11)
2021-07-20T09:34:24.3394740Z     at Socket.emit (events.js:198:13)
2021-07-20T09:34:24.3497070Z     at Pipe._handle.close (net.js:607:12)
2021-07-20T09:34:25.0333940Z No test result files matching /Users/runner/work/1/s/**/TEST-*.xml were found, so publishing JUnit test results is being skipped.
2021-07-20T09:34:25.0400950Z ##[error]Error: The process '/Users/runner/work/1/s/tests/android/sample-app-tests/gradlew' failed with exit code 1
2021-07-20T09:34:25.0445700Z ##[section]Finishing: Run Android tests

@miketimofeev
Copy link
Contributor

@luissilvaos yes, it looks like the project still tries to use build-tools 31. Is it possible to create minimal repro steps? I assume that some configuration needs to be changed.
Have you tried any of the workarounds mentioned here #3757 (comment)?

@luissilvaos
Copy link

luissilvaos commented Jul 21, 2021

@luissilvaos yes, it looks like the project still tries to use build-tools 31. Is it possible to create minimal repro steps? I assume that some configuration needs to be changed.

Yes, but I have no reference for build-tools 31 nor sdk 31. Everything was working as planned/expected until a couple of days ago.
Here is my project configuration:

android {
    compileSdkVersion 30
    buildToolsVersion '30.0.3'

    defaultConfig {
        minSdkVersion 23
        targetSdkVersion 30
    }
}

Have you tried any of the workarounds mentioned here #3757 (comment)?

Yes, I managed to overcome this just by uninstalling build-tools 31.

@miketimofeev
Copy link
Contributor

@luissilvaos I can only guess that this setting is not picked up by the build system, but, unfortunately, we couldn't help you without repro-steps.

@shankari
Copy link
Author

@luissilvaos can you add instructions to programatically uninstall build-tools 31 in a GHA here? It will save the rest of us a lot of time 😄

@miketimofeev
Copy link
Contributor

@shankari you can find uninstallation steps in this comment
#3757 (comment)
But I'm afraid the next build tools version (31.0.1?) will also break your workflow.

@dschwank
Copy link

  • Create a symlink from d8 to dx:
ln -s ${ANDROID_HOME}/build-tools/31.0.0/d8 ${ANDROID_HOME}/build-tools/31.0.0/dx

@miketimofeev The proposed workaround worked "almost" for me, I just had to add an additional link for the dx.jar. So the following setup works for me as expected:

ln -s ${ANDROID_HOME}/build-tools/31.0.0/d8 ${ANDROID_HOME}/build-tools/31.0.0/dx
ln -s ${ANDROID_HOME}/build-tools/31.0.0/lib/d8.jar ${ANDROID_HOME}/build-tools/31.0.0/lib/dx.jar

@luissilvaos I also had the issue with cordova, that it ignored the buildToolsVersion. Linking the the version like described above solved the issue for me.

@luissilvaos
Copy link

luissilvaos commented Jul 23, 2021

@miketimofeev here are the repro steps:

jobs:
  build:
    runs-on: macos-latest

    steps:
      - name: Setup Node.js environment
        uses: actions/setup-node@v2.3.0
        with:
          node-version: 14.x
      
      - name: Install Cordova
        run: npm install -g cordova

      - name: Create and build cordova android app
        run: |
          cordova create app --verbose
          cd app
          cordova platform add android --verbose
          cordova build --verbose

The project will use Android Build Tools 29.0.2 and it will fail due to the corrupted build tools 31.

@gopi-hl
Copy link

gopi-hl commented Jul 23, 2021

Is it possible to specify a previous ImageVersion ?

Current image version: 20210719.0 fails,
Current image version: 20210711.0 succeeds,

@al-cheb
Copy link
Contributor

al-cheb commented Jul 23, 2021

Is it possible to specify a previous ImageVersion ?

Current image version: 20210719.0 fails,
Current image version: 20210711.0 succeeds,

Currently, we can't specify a particular version.

@gopi-hl
Copy link

gopi-hl commented Jul 23, 2021

Also, are we tracking both Windows and OSX here in the same bug?

@miketimofeev
Copy link
Contributor

@gopi-hl yes, as the issue is the same for all OSs.

@miketimofeev
Copy link
Contributor

@luissilvaos Unfortunately, it turned out that there is a bug in Cordova that prevents pinning build-tools version:
apache/cordova-android#1290

@gopi-hl
Copy link

gopi-hl commented Jul 23, 2021

I observed it fails in cordova-android @9.0.0 too.

ionic cordova build android --prod --release -- -- --gradleArg=-PcdvBuildToolsVersion=30.0.2

@gopi-hl
Copy link

gopi-hl commented Jul 23, 2021

Fixed in 10.0 though -

#apache/cordova-android#659 (comment)

@miketimofeev
Copy link
Contributor

@gopi-hl but doesn't work for some reason
apache/cordova-android#1288

@luissilvaos
Copy link

@luissilvaos Unfortunately, it turned out that there is a bug in Cordova that prevents pinning build-tools version:
apache/cordova-android#1290

I can confirm you that this is caused by cordova. One of my projects start building after removing the dependency for cordova. Thanks for your help!

@gopi-hl
Copy link

gopi-hl commented Jul 23, 2021

@gopi-hl but doesn't work for some reason
apache/cordova-android#1288

apache/cordova-android#1290 (comment) :(

@gopi-hl
Copy link

gopi-hl commented Jul 23, 2021

So, as of now, the only workaround is to not have version 31 installed on the image. Why is it so hard to remove? Seems like it is causing more issues than what the upgrade is worth.

Atleast, until GOOG fixes it?
Or until cordova-android fixes it.

@dschwank
Copy link

@gopi-hl I had the same issues with cordova. As a workaround, linking the files worked fine for me - like mentioned here: #3757 (comment)

Have you tried that?

@gopi-hl
Copy link

gopi-hl commented Jul 23, 2021

@gopi-hl I had the same issues with cordova. As a workaround, linking the files worked fine for me - like mentioned here: #3757 (comment)

Have you tried that?

I use a Windows 2019 machine for builds (Azure DevOps) - so have to figure how this translates to the command line. For some reason, a Mac/Ubuntu machine never worked for me well for my ionic app.

@miketimofeev
Copy link
Contributor

miketimofeev commented Jul 23, 2021

@gopi-hl I'm afraid google won't fix it as dx compiler deprecation was planned and all the future build-tools will be released without it and will have this issue as well, that's why we wouldn't like to remove that particular version.
You can use the following Powershell snippet to uninstall build-tools 31 on windows, it takes about 5s:

$sdkmanager = "$env:ANDROID_SDK_ROOT\cmdline-tools\latest\bin\sdkmanager.bat"
& $sdkmanager --uninstall "build-tools;31.0.0"

@gopi-hl
Copy link

gopi-hl commented Jul 23, 2021

@gopi-hl I'm afraid google won't fix it as dx compiler deprecation was planned and all the future build-tools will be released without it and will have this issue as well, that's why we wouldn't like to remove that particular version.
You can use the following Powershell snippet to uninstall build-tools 31 on windows, it takes about 5s:

$sdkmanager = "$env:ANDROID_SDK_ROOT\cmdline-tools\latest\bin\sdkmanager.bat"
& $sdkmanager --uninstall "build-tools;31.0.0"

Thank you @miketimofeev ! Works like a charm.

@BapuHirave
Copy link

We are building react native apps using VS AppCenter. Android builds no longer able to install. and in appCenter pipeline, we cant configure build os version. This is big blocker for us now.

here is our android build configuration

 buildToolsVersion = "29.0.2"
 minSdkVersion = 23
 compileSdkVersion = 29
 targetSdkVersion = 29

Can someone help us here ? what should we put for buildToolsVersion ?

Thanks

@miketimofeev
Copy link
Contributor

@bhirave one of the possible workarounds is to use a pre-build script that deletes the latest build-tools
https://docs.microsoft.com/en-us/appcenter/build/custom/scripts/
Script content:

SDKMANAGER=$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager
echo y | $SDKMANAGER --uninstall "build-tools;31.0.0"

@miketimofeev
Copy link
Contributor

@shankari and all the others who experience the issue with cordova — could you try the new 10.0.1 versions that allows to pin build-tools version?
https://cordova.apache.org/announcements/2021/07/30/cordova-android-10.0.1.html

@shankari
Copy link
Author

@miketimofeev paper deadline Apr 1st, which is why I haven't even implemented the simple workarounds so far. Will implement the workaround first thing next week, but will experiment with the newer version sometime the week after that.
Sorry, but I know that there will be a huge backlog to catch up on after the deadline is done.

@BapuHirave
Copy link

BapuHirave commented Jul 30, 2021

@bhirave one of the possible workarounds is to use a pre-build script that deletes the latest build-tools
https://docs.microsoft.com/en-us/appcenter/build/custom/scripts/
Script content:

SDKMANAGER=$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager
echo y | $SDKMANAGER --uninstall "build-tools;31.0.0"

@miketimofeev you rock. We are able to unblock ourselves using prebuild script. Thank you again for prompt reply.

shankari added a commit to shankari/e-mission-phone that referenced this issue Aug 10, 2021
Workaround from
actions/runner-images#3757 (comment)
until we upgrade to the most recent version of cordova

Other fixes:
- rename the android CI workflow to clarify that we only build on OSX
- highlight the tools uninstallation in the README
@miketimofeev
Copy link
Contributor

The issue seems to be resolved on Cordova side.

@shankari
Copy link
Author

wrt

@shankari and all the others who experience the issue with cordova — could you try the new 10.0.1 versions that allows to pin build-tools version? https://cordova.apache.org/announcements/2021/07/30/cordova-android-10.0.1.html

I don't see any explicit confirmation here, so for the record, I upgraded to cordova-android@10.0
and removed the workaround and everything works
e-mission/e-mission-phone#804

@keithdmoore94
Copy link

Here is an action with the above solution that worked for me:

  - name: Fix build tools 31 issue
    run: | 
      ln -s ${ANDROID_HOME}/build-tools/31.0.0/d8 ${ANDROID_HOME}/build-tools/31.0.0/dx
      ln -s ${ANDROID_HOME}/build-tools/31.0.0/lib/d8.jar ${ANDROID_HOME}/build-tools/31.0.0/lib/dx.jar

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Android Area: Image administration investigate Collect additional information, like space on disk, other tool incompatibilities etc. OS: macOS
Projects
None yet
Development

No branches or pull requests

10 participants