timpark opened a new issue #981:
URL: https://github.com/apache/cordova-android/issues/981


   # Bug Report
   
   ## Problem
   
   The plugin.xml file of cordova-plugin-local-notifications contains the line:
   `<engine name="android-sdk" version=">=26" />`
   
   This plugin refused to install on the Nevercode CI platform even though 
android-29 was installed, because I discovered that (at the time, at least) 
their build environments have three Android Preview SDKs installed.
   
   The issue is that when android_sdk.js encounters an SDK version without a 
number at the end (in my case, android-P, android-Q, and android-R), it refuses 
to move it, and depending on where it is in relation to other versions, it can 
block proper sorting of the SDKs.
   
   ### What is expected to happen?
   
   Plugin should install since a version of the SDK is installed matching the 
requirements.
   
   ### What does actually happen?
   
   Plugin did not install.
   
   ## Information
   <!-- Include all relevant information that might help understand and 
reproduce the problem -->
   
   Attempt to build a project with the cordova-plugin-local-notifications 
plugin (or any other with a similar requirement) with Android Preview SDKs 
installed.
   
   ### Command or Code
   <!-- What command or code is needed to reproduce the problem? -->
   
   Here's a patch that, instead of not moving the preview versions at all, 
gives them a version of 0 so they get sent to the end of the list.
   
   ```
   --- android_sdk.js   2020-05-26 14:33:04.000000000 -0400
   +++ android_sdk_new.js       2020-05-26 14:50:38.000000000 -0400
   @@ -31,15 +31,12 @@
    function sort_by_largest_numerical_suffix (a, b) {
        var suffix_a = a.match(suffix_number_regex);
        var suffix_b = b.match(suffix_number_regex);
   -    if (suffix_a && suffix_b) {
   -        // If the two targets being compared have suffixes, return less than
   -        // zero, or greater than zero, based on which suffix is larger.
   -        return (parseInt(suffix_a[1]) > parseInt(suffix_b[1]) ? -1 : 1);
   -    } else {
   -        // If no suffix numbers were detected, leave the order as-is between
   -        // elements a and b.
   -        return 0;
   -    }
   +    // If no number is detected (eg: preview version like android-R),
   +    // designate a suffix of 0 so it gets moved to the end
   +    suffix_a = suffix_a ? suffix_a : ['0','0'];
   +    suffix_b = suffix_b ? suffix_b : ['0','0'];
   +    // Return < zero, or > zero, based on which suffix is larger.
   +    return (parseInt(suffix_a[1]) > parseInt(suffix_b[1]) ? -1 : 1);
    }
    
    module.exports.print_newest_available_sdk_target = function () {
   ```
   
   Perhaps the preview SDKs would be given a proper number, but that's more 
complicated than what I needed.  Either way, it was causing my plugin install 
to fail on Nevercode.  Due to the ordering of the installed SDKs, 15 got moved 
to the front instead of 29.
   
   Sorry I didn't submit a pull request, but I'm not sure how to properly meet 
the required testing criteria with a bug like this.
   
   
   ### Environment, Platform, Device
   <!-- In what environment, on what platform or on which device are you 
experiencing the issue? -->
   
   Nevercode CI with what looked like every Android SDK in existence installed
   
   ### Version information
   <!-- 
   What are relevant versions you are using?
   For example:
   Cordova: Cordova CLI, Cordova Platforms, Cordova Plugins 
   Other Frameworks: Ionic Framework and CLI version
   Operating System, Android Studio, Xcode etc.
   -->
   
   Cordova CLI 9.0.0
   Cordova-Android 8.1.0
   Ionic 3.20.1
   
   ## Checklist
   <!-- Please check the boxes by putting an x in the [ ] like so: [x] -->
   
   - [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
   


----------------------------------------------------------------
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:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to