Error: Cannot read property 'replace' of undefined [Android]

Hi,

I just came across the same problem. I tracked it down to file /platforms/android/cordova/lib/emulator.js line 202:

var num = target.split(’(API level ‘)[1].replace(’)’, ‘’);

I replaced it with a regex search and extraction:

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

It fixed the issue in my case. Nevertheless after that I still had a problem (I do not now if you are going to encounter it as well): the emulator launched but my application did not. This happens when I run the emulator for the first time. When it is already opened and I rerun the command “ionic cordova emulate android” the application starts.

17 Likes