Fix error message when installed build tools version greater than MIN_BUILD_TOOLS_VERSION + 1
See original GitHub issueBug Report
Problem
I have build tools 32 installed. Compiling an android application using cordova-android 10.1.1 fails with the message:
This is clearly misleading and led me to waste a fair amount of time trying to track down the real problem
What is expected to happen?
Compilation should fail and display an error message indicating the required versions of build tools, something like
No usable build tools found. Android build tools version should be between 30.0.3 and 31.0.0.
What does actually happen?
Compilations fails with the message:
No installed build tools found. Install the Android build tools version 30.0.3 or higher.
Information
There are related issues about the compilation failing, but they don’t address the problem of the misleading error message: https://github.com/apache/cordova-android/issues/1288 https://github.com/apache/cordova-android/issues/1335
Command or Code
cordova compile android
Environment, Platform, Device
Windows 10.
Version information
Cordova cli 11.0.0 Cordova android 10.1.1
Checklist
- [ x] I searched for existing GitHub issues
- [ x] I updated all Cordova tooling to most recent version
- [ x] I included all the necessary information above
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:5 (2 by maintainers)
In regards to the error message, it’s definitely an oversight. It should be more descriptive.
The code in question attempts to automatically find the latest version of build tools that is installed, but it should not automatically choose the next major version. Doing so is error prone as major version jumps generally indicate some sort of breaking change.
android-buildToolsVersion
preference should forcefully allow a particular build tools version but changing the build tools version will likely cause build issues. E.g. cordova-android@10 is only tested with API 30 and there are known incompatibilities with version build tools 31. I doubt build tools 32 will work right now.I had this same problem and finally found the problem in
cordova.gradle
, line 57:def maxVersion = new Version((minBuildToolsVersion.getMajor() + 1) + ".0.0")
… and then line 62:
.findAll { it.isHigherThan('0.0.0') && it.isLowerThan(maxVersion) }
Is there a good reason for setting a
maxVersion
to be no more than 1 major version higher thanminversion
? At a minimum, the error message should change to reflect what the highest allowed version is, not just say “version 30.0.3 or higher.” I spent a lot of time tracking this down.I’m using Cordova 11 with build tools 32, on a brand new Mac mini.
Thanks!
EDIT: Ah, I see that using any build tools above 30.0.3 won’t work correctly, so there is indeed that good reason to have a
maxVersion
. (Build tools 30.0.3 is the only version supported by Android Studio that works here-- versions 31.x and 32.x lead to “Installed Build Tools revision X is corrupted.”). Anyway, I uninstalled version 32 and installed 30.0.3 and it seems to work correctly now.