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

Fix error message when installed build tools version greater than MIN_BUILD_TOOLS_VERSION + 1 #1391

Closed
cdmahoney opened this issue Jan 17, 2022 · 5 comments · Fixed by #1401

Comments

@cdmahoney
Copy link

Bug 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:
#1288
#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
@jmarshall-com
Copy link

jmarshall-com commented Feb 4, 2022

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 than minversion? 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.

@breautek
Copy link
Contributor

breautek commented Feb 4, 2022

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.

@jmarshall-com
Copy link

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.

Gotcha, thanks. It's indeed working now with version 30.0.3 .

@bhandaribhumin

This comment was marked as off-topic.

breautek added a commit to breautek/cordova-android that referenced this issue Feb 22, 2022
@breautek
Copy link
Contributor

I've resolved this by rewording the the error message to something like:

  • What went wrong:
    A problem occurred evaluating script.
    No installed build tools found. Please install the Android build tools version 30.0.3.

I left it open ended so that the error message will ask for the minimum/recommended version that Cordova uses. Users can still install an alternate version for testing/if they know what they are doing using the preferences.

breautek added a commit that referenced this issue Feb 22, 2022
wedgberto pushed a commit to wedgberto/cordova-android that referenced this issue May 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants