From 109112ae752dcd2641a320b3451c992f57916170 Mon Sep 17 00:00:00 2001 From: Chris Alfano Date: Fri, 22 Dec 2017 15:54:12 -0500 Subject: [PATCH] CB-13571: (android) Prevent crash with unrecognized android version 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 --- bin/templates/cordova/lib/emulator.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bin/templates/cordova/lib/emulator.js b/bin/templates/cordova/lib/emulator.js index 0a23084e..305e2e3d 100644 --- a/bin/templates/cordova/lib/emulator.js +++ b/bin/templates/cordova/lib/emulator.js @@ -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;