breautek opened a new pull request #985: URL: https://github.com/apache/cordova-android/pull/985
<!-- Please make sure the checklist boxes are all checked before submitting the PR. The checklist is intended as a quick reference, for complete details please see our Contributor Guidelines: http://cordova.apache.org/contribute/contribute_guidelines.html Thanks! --> ### Platforms affected android ### Motivation and Context <!-- Why is this change required? What problem does it solve? --> <!-- If it fixes an open issue, please link to the issue here. --> Fixes #981 If a plugin declares a `android-sdk` engine requirement such as `<engine name="android-sdk" version=">=26" />` the plugin may unexpectedly fail if the following conditions are met: 1. You have an appropriate SDK version installed (such as version `android-28`) 2. You have android preview SDK installed. If the android preview SDK is installed, it was treated as the highest sdk version, even if it has no numerical value. This then led to errors such as: ``` Installing "cordova-plugin-local-notification" for android Failed to install 'cordova-plugin-local-notification': TypeError: Invalid Version: android-R at new SemVer (/home/norman/.nvm/versions/node/v14.2.0/lib/node_modules/cordova/node_modules/semver/semver.js:323:11) at Range.test (/home/norman/.nvm/versions/node/v14.2.0/lib/node_modules/cordova/node_modules/semver/semver.js:1203:15) at Function.satisfies (/home/norman/.nvm/versions/node/v14.2.0/lib/node_modules/cordova/node_modules/semver/semver.js:1257:16) at checkEngines (/home/norman/.nvm/versions/node/v14.2.0/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/install.js:113:20) at /home/norman/.nvm/versions/node/v14.2.0/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/install.js:305:16 at processTicksAndRejections (internal/process/task_queues.js:97:5) Invalid Version: android-R ``` ### Description <!-- Describe your changes in detail --> This PR changes the `sort_by_largest_numerical_suffix` and give preview SDKs a numerical value of 0, thus preview SDKs are put to the bottom of the stack. This does mean that preview SDKs will never be chosen, but I believe this should be the default behaviour. If the user wants to use a preview SDK, I think that should be an opt-in feature, and it is out of scope of this PR. Existing tests were modified to ensure that preview SDKs were ordered properly. Special thanks to @timpark for supplying a patch that fixes the `sort_by_largest_numerical_suffix` method. ### Testing <!-- Please describe in detail how you tested your changes. --> I've ran `npm test` I've tested against the my local fork with the PR applied, using the following commands on an empty project. ``` cordova platform add (android | android-fork) cordova plugin add https://github.com/Steffaan/cordova-plugin-local-notifications ``` ### Checklist - [x] I've run the tests to see all new and existing tests pass - [x] I added automated test coverage as appropriate for this change - [x] Commit is prefixed with `(platform)` if this change only applies to one platform (e.g. `(android)`) - [x] If this Pull Request resolves an issue, I linked to the issue in the text above (and used the correct [keyword to close issues using keywords](https://help.github.com/articles/closing-issues-using-keywords/)) - [x] I've updated the documentation if necessary ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@cordova.apache.org For additional commands, e-mail: issues-h...@cordova.apache.org