I am first time user of Ionic. The version is now 3.3
I did default app create and resulting in a app that is functioning in the web browser when doing a ionic serve
However,
doing a
ionic cordova emulate android
results in the below error
BUILD SUCCESSFUL
Total time: 1.428 secs
Built the following apk(s):
/Volumes/LUN-NAS3-MISC/CordovaApps/myApp/platforms/android/build/outputs/apk/android-debug.apk
ANDROID_HOME=/Applications/AndroidDev/sdk
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home
Error: Cannot read property āreplaceā of undefined
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.
I got the same error message too, and as @rapropos say, this is a common error message so googling has not been of much help.
Unfortunately, I have no idea how to get the stacktrace (I tried ionic cordova run android --stacktrace but to no avail).
This is what I get when I ran ionic info:
global packages:
@ionic/cli-plugin-proxy : 1.3.0
@ionic/cli-utils : 1.3.0
Cordova CLI : 7.0.1
Ionic CLI : 3.3.0
local packages:
@ionic/app-scripts : 1.3.7
@ionic/cli-plugin-cordova : 1.3.0
@ionic/cli-plugin-ionic-angular : 1.3.0
Cordova Platforms : android 6.2.3
Ionic Framework : ionic-angular 3.3.0
System:
Node : v7.2.1
OS : macOS Sierra
Xcode : Xcode 8.3 Build version 8E162
ios-deploy : not installed
ios-sim : not installed
Basically, I am trying to test my ionic app on my android device by connecting it to my macbook proā¦Can someone let me know how to pinpoint the source of error? Thanks!
BUILD SUCCESSFUL
Total time: 2.862 secs
Built the following apk(s):
/Users/Joanne/Desktop/learning/mobile/platforms/android/build/outputs/apk/android-debug.apk
ANDROID_HOME=/Users/Joanne/Library/Android/sdk
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home
No target specified and no devices found, deploying to emulator
Error: Cannot read property 'replace' of undefined
[ERROR] Cordova encountered an error.
You may get more insight by running the Cordova command above directly.
[DEBUG] !!! ERROR ENCOUNTERED !!!
[ERROR] An error occurred while running cordova run android (exit code 1).
and [quote=āSujan12, post:19, topic:93297ā]
cordova run android --stracktrace
[/quote]
gives:
BUILD SUCCESSFUL
Total time: 1.601 secs
Built the following apk(s):
/Users/Joanne/Desktop/learning/mobile/platforms/android/build/outputs/apk/android-debug.apk
ANDROID_HOME=/Users/Joanne/Library/Android/sdk
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home
No target specified and no devices found, deploying to emulator
Error: Cannot read property 'replace' of undefined
This is definitely an issue in cordova-android, the library Cordova uses for Android. Something goes wrong when it tries to get the list of emulators or something like that.
You (and the others having this problem) should search for an issue or report an issue at https://issues.apache.org/jira/projects/CB/issues (Include the complete output of cordova buid android --stracktrace)