-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Android build fails with Android SDK Build-Tools 31.0.0 #1288
Comments
WorkaroundMy first attempt to work around this issue was upgrading to cordova-android 10.0.0, and my second one was pinning the Android SDK Build-Tools version as seen above. When both failed, uninstalling the offending dependency did the trick. It can be done in Android Studio or on the command line:
|
Migrated this to cordova-android for you since this is the package that is responsible for handling the android environment. Our supported API level on cordova-android@10 is API 30, so build-tools version 30 should work. I've placed this issue in the 11.x milestone because generally we only officially support the next API level in a major releases. However, if it is possible to fix this without introducing breaking changes, then we may include it in a future minor release. Currently cordova-android will look for the latest installed version of build tools, which is probably a bad idea for this very reason. Which is why the uninstalling build-tools 31 is the necessary workaround. |
@breautek am I right that none of these options will work and there is no way to pin the build-tools version? |
Correct, and further investigation on the "why" identifies another bug. The desired build tools get set here:
cordova-android/framework/cordova.gradle Lines 175 to 177 in 0ce6624
Where In fact, this behaviour did change as cordova-android 9.1 did: cordova-android/bin/templates/project/app/build.gradle Lines 164 to 167 in c9108d8
And only used |
Hey @kputh C:\Users\User\AppData\Local\Android\Sdk\build-tools\31.0.0 Then find the file d8 (Windows batch file) and rename it to dx. Then go to: C:\Users\User\AppData\Local\Android\Sdk\build-tools\31.0.0\lib Then find the file d8 (Executable Jar File) and rename is to dx. Your problem will be solved now. I have also the same problem which gets resolved with above solution |
@pawan-logiciel, thank you for the workaround. Unfortunately, I can't use it in out build pipeline |
Sorry, I hit the wrong button. |
The PR #1293 should provide a better workaround (by fixing the actual gradle arg parameter). Hoping it will be reviewed and be included in our patch release. |
We also merged in #1294 which will fix cordova-android to not blindly take in any build tools version, but limit the scope to use the latest patch of a particular major version. We are planning on doing a patch release sometime soon (cannot give any more details then that) so this should address the issue without using any actual parameters, though using the gradle argument to pin to a specific version might be still ideal. As for supporting build tools 31, it looks like cordova android needs to use AGP 7 which also requires Java 11. These are all breaking changes, so I'll leave this issue open and inside our 11.x milestone. |
I'm working with Ionic and it's forcing me to use cordova-android 9.1.0 and I'm getting the same error build tools 31.0.0 I found out that in the cordovaLib module that is generated, in build.gradle it generates with this snippet
Which makes any attempt to change buildtools by environment variable or arguments impossible, because it will always use the most current version installed on the machine. What is simple to be solved in a local development, boring but simple. But now to update on my CI/CDs that already come with all versions available to me, what do I do? I only see two work around
|
@LucasFebatis android version 10.0.1 (unreleased, pending votes) will fix the platform so that it will find the latest build tools release of a specific major rather than blindly choosing the latest available. Additionally the same version also fixes the flag (regression introduced in 10.0.0) so that if declared it will use a specific build tools version of your choice, as long as it's >= our minimum build tools version. You can give it a try by installing the nightly version. Note that Cordova android 9.x won't be patched. |
Hi there. (before that message, I receive "Build-tool 31.0.0 rc5 is missing DX at C:\Users*\AppData\Local\Android\sdk\build-tools\31.0.0-rc5\dx.bat") Shouldnt the Fix only consider Build Tools from 30.* instead of 31? Thanks! |
if any one using Azure devOps, Microsoft hosted macOS agents, adding this as a command-line task before the build should do |
cordova-android@10.0.1 does include a patch that does just that. I wonder if the pre-release label however is causing problems. This was tested against a production release version (e.g. version |
Just adding a note that I adopted @breautek's work around from this comment: #1288 (comment) His workaround pointed me in the right direction, but I needed to make a few changes.... The error I was seeingWhat brought me to this thread was seeing this error message:
Then when I upgraded to 31.0.0, I realized that did not work either 😅 First, I had a different ENV varI saw @breautek's comment and noticed his variable was
So I changed the command to:
I then installed version 30.0.3:
Hope this helps as people smarter than me helps diagnose an actual solution 🤓 Thanks for your hard work! |
Hey Norman, |
@pawan-logiciel saved by day! |
Sorry for the late response. I'm not sure if I'm fully understanding your statement but Build Tools 31 requires breaking changes to be done on our end. I don't think we need a new ticket for this, I think this ticket is sufficient is in our cordova-android@11 milestone so we can keep track of issues required to be resolved once cordova-android@11 development starts. |
Yes Build 31 does not work - so I went back a version and it did compile but once again sending to the android emulator fails to engage - you have to manually open the emulator first - same old issue. |
Ok, emulator usage is definitely not related to this issue and should be reported as a separate ticket. |
I confirm this works. Solution for me. |
I got version 10.1.0 And seems does not solve the issue I manually changed it in Android Studio to 30.0.3 |
Hi @breautek, I have doubt that cordova build android --release -- --gradleArg=-PcdvBuildToolsVersion=30.0.3 by using this the app can able to work on Android 11 devices. Thanks in advance. |
Any update on this? also android platform 32 and built tools 32.0.0 have already been released! |
Bro I spent all day trying to get the Android Mobile setup for the Unreal Engine and this absolutely worked....I'm running on Windows 11 so I don't know if that had anything to do with it. Your comment made my day. |
Resolved by #1427 |
Bug Report
Problem
When I run
I get the following error:
The build seems to ignore the pinned Android Build-Tools version.
This issue started appearing in our build pipeline between July 19., 13:20 UTC and July 20., 08:38 UTC. I can't tell when the Android SDK Build-Tools 31.0.0 were release, but cordova-android 10.0.0 was release July 20., 04:17 (timezone?). That may be no coincidence.
What is expected to happen?
The build should succeed.
What does actually happen?
The build fails.
Information
Command or Code
Environment, Platform, Device
Azure Pipelines, vmImage 'macOS-10.15', and local development (see below)
Version information
Cordova Packages:
Project Installed Platforms:
Project Installed Plugins:
Environment:
Checklist
The text was updated successfully, but these errors were encountered: