Closed kputh closed 1 year ago
My 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:
$ANDROID_HOME/tools/bin/sdkmanager --uninstall "build-tools;31.0.0"
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?
@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:
LATEST_INSTALLED_BUILD_TOOLS
gets set by:
Where BUILD_TOOLS_VERSION
is comes from the config shown in your docs screenshot. As the doFindLatestInstalledBuildTools
function name might suggest, it finds the latest build tools version, with the parameter being the "minimum" required version.
In fact, this behaviour did change as cordova-android 9.1 did:
And only used findLatestInstalledBuildTools
if the user parameter wasn't specified. I do believe this wasn't intentional and this issue probably should be reported as a separate issue, which I've already done here.
Hey @kputh In order to fix the issue, firstly go to the following location:
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 https://github.com/apache/cordova-android/pull/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 https://github.com/apache/cordova-android/pull/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
ext {
apply from: 'cordova.gradle'
cdvCompileSdkVersion = privateHelpers.getProjectTarget()
cdvBuildToolsVersion = privateHelpers.findLatestInstalledBuildTools()
if (project.hasProperty('cdvMinSdkVersion') && cdvMinSdkVersion.isInteger()) {
cdvMinSdkVersion = cdvMinSdkVersion as int
println '[Cordova] cdvMinSdkVersion is overridden, try it at your own risk.'
} else {
cdvMinSdkVersion = 22; // current Cordova's default
}
}
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
Create a vm image with the version of BuildTools I need (Too much work)
Create a step to replace the generated build.gradle with a template (Which is really annoying, since one day Android or Cordova or Ionic will fix these problems, and then I'll have to discard this step)
@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. After "cordova platform add android@10.0.1" and then "cordova build" (without any Plugins, just the Skeleton App), I still get "Failed to find Build Tools revision 31.0.0-rc5". What am I missing?
(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
SDKMANAGER=$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager echo y | $SDKMANAGER --uninstall "build-tools;31.0.0"
(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!
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 31.0.0
).
Just adding a note that I adopted @breautek's work around from this comment: https://github.com/apache/cordova-android/issues/1288#issuecomment-884423978
His workaround pointed me in the right direction, but I needed to make a few changes....
What brought me to this thread was seeing this error message:
No usable Android build tools found. Highest 30.x installed version is 30.0.2; minimum version required is 30.0.3.
Then when I upgraded to 31.0.0, I realized that did not work either 😅
I saw @breautek's comment and noticed his variable was ANDROID_HOME
, but mine was ANDROID_SDK_ROOT
. Thankfully I noticed this in my logs:
ANDROID_SDK_ROOT=/Users/jay/Library/Android/sdk (recommended setting)
ANDROID_HOME=undefined (DEPRECATED)
$ANDROID_SDK_ROOT/tools/bin/sdkmanager --uninstall "build-tools;31.0.0"
$ANDROID_SDK_ROOT/tools/bin/sdkmanager --install "build-tools;30.0.3"
Hope this helps as people smarter than me helps diagnose an actual solution 🤓
Thanks for your hard work!
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.
Hey Norman, I agree it needs to addressed correctly. I just removed the 31 sdk - works ok BUT- and yes - another 6 months has passed :) - it does NOT invoke the emulator automatically - it has to be open to be seen by Cordova - an issue ( we - you ) finally fixed last round.. Do I open a new ticket for this? Phil
@pawan-logiciel saved by day!
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.
Hey Norman, I agree it needs to addressed correctly. I just removed the 31 sdk - works ok BUT- and yes - another 6 months has passed :) - it does NOT invoke the emulator automatically - it has to be open to be seen by Cordova - an issue ( we - you ) finally fixed last round.. Do I open a new ticket for this? Phil
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.
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.
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 seeing
What brought me to this thread was seeing this error message:
No usable Android build tools found. Highest 30.x installed version is 30.0.2; minimum version required is 30.0.3.
Then when I upgraded to 31.0.0, I realized that did not work either
First, I had a different ENV var
I saw @breautek's comment and noticed his variable was
ANDROID_HOME
, but mine wasANDROID_SDK_ROOT
. Thankfully I noticed this in my logs:ANDROID_SDK_ROOT=/Users/jay/Library/Android/sdk (recommended setting) ANDROID_HOME=undefined (DEPRECATED)
So I changed the command to:
$ANDROID_SDK_ROOT/tools/bin/sdkmanager --uninstall "build-tools;31.0.0"
I then installed version 30.0.3:
$ANDROID_SDK_ROOT/tools/bin/sdkmanager --install "build-tools;30.0.3"
Hope this helps as people smarter than me helps diagnose an actual solution
Thanks for your hard work!
I confirm this works. Solution for me.
(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!
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
31.0.0
).
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!
Hey @kputh In order to fix the issue, firstly go to the following location:
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
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.
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