Skip to content

Commit

Permalink
CB-13571: (android) Prevent crash with unrecognized android version
Browse files Browse the repository at this point in the history
Fixes issue where commands that list images will crash when an image with a version not present in `android-versions` is encountered, as is presently the case with API 27:

```
cordova run android --list
Available android devices:
Available android virtual devices:
LEVEL: null
ERROR: TypeError: Cannot read property 'semver' of null
An unexpected error has occured while running list-emulator-images with code 2: Error: /home/chris/Repositories/acp-guidelines/cordova/platforms/android/cordova/lib/list-emulator-images: Command failed with exit code 2
```

Signed-off-by: Chris Alfano <chris@jarv.us>
  • Loading branch information
themightychris committed Dec 22, 2017
1 parent a24ba41 commit 109112a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion bin/templates/cordova/lib/emulator.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,9 @@ module.exports.list_images = function () {
var api_level = avd.target.match(/\d+/);
if (api_level) {
var level = android_versions.get(api_level);
avd.target = 'Android ' + level.semver + ' (API level ' + api_level + ')';
if (level) {
avd.target = 'Android ' + level.semver + ' (API level ' + api_level + ')';
}
}
}
return avd;
Expand Down

4 comments on commit 109112a

@BJGDEV
Copy link

@BJGDEV BJGDEV commented on 109112a Dec 27, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@janpio
Copy link
Member

@janpio janpio commented on 109112a Dec 27, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

@BJGDEV
Copy link

@BJGDEV BJGDEV commented on 109112a Dec 27, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mrweiland
Copy link

@mrweiland mrweiland commented on 109112a Apr 12, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Im using cordova 7.0.0 and this is still a problem? It works when i changed this line of code but little annoying need to do it all the time...

Please sign in to comment.