Q:

Cordova android emulator "cannot read property 'replace' of undefined"

Have just installed the latest version of Apache Cordova (7.0.1) on Windows, the Android SDK, added the android platform, and when trying to run the android emulator it compiles everything ok but then shows a:

Cannot read property 'replace' of undefined

Without indication or anything else to trace the error.

A:

In the Ionic framework forum found the following answer that solved the problem:

Tracked it down to file /platforms/android/cordova/lib/emulator.js
  line 202:
var num = target.split('(API level ')1.replace(')', '');
Replace it with a regex search and extraction:
var num = target.match(/\d+/)[0];

A:

Happened with me this week.
Try to downgrade Android platform to 6.0.0 until ionic team resolve this issue.
Commands: 
cordova platform rm Android
cordova platform add Android@6.0.0 

A:

If you'd rather not modify emulator.js (Adrian's answer), I was able to work around this issue by manually starting an Android virtual device before running cordova emulate android.

