ionic cordova emulate android : Cannot read property 'replace' of undefined

Plus moyen de lancer l'emulator Android ?

//// erreur
An error occurred while running cordova emulate android (exit code 1).

ANDROID_HOME=C:\Users\Sam\AppData\Local\Android\sdk  
JAVA_HOME=C:\Program Files\java\jdk1.8.0_144  
Error: Cannot read property 'replace' of undefined

[ERROR] An error occurred while running cordova emulate android (exit code 1).

La solution est simple : il suffit de modifier le fichier

platforms/android/cordova/lib/emulator.js ligne 202  

et plus précisément la ligne 202

// KO
var num = target.split('(API level ')[1].replace(')', '');

par

// OK
var num = target.match(/\d+/)[0];

Ce qui donne

// solution : platforms/android/cordova/lib/emulator.js ligne 202
module.exports.best_image = function() {  
    return this.list_images()
    .then(function(images) {
        // Just return undefined if there is no images
        if (images.length === 0) return;

        var closest = 9999;
        var best = images[0];
        var project_target = check_reqs.get_target().replace('android-', '');
        for (var i in images) {
            var target = images[i].target;
            if(target) {
                // KO
                // var num = target.split('(API level ')[1].replace(')', '');   
                // OK
                var num = target.match(/\d+/)[0];                                 
                if (num == project_target) {
                    return images[i];
                } else if (project_target - num < closest && project_target > num) {
                    closest = project_target - num;
                    best = images[i];
                }
            }
        }
        return best;
    });
};