Reputation: 1115
I'm running into trouble trying to run
ionic emulate android
I get an error which says Error: android: Command failed with exit code 2
. But, it does say BUILD SUCCESSFUL
.
What I'm running
I have set up environment variables in my .bashrc:
export ANDROID_HOME=$HOME/Android/Sdk
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
Here is the the bottom of the output for ionic emulate android
UP-TO-DATE
BUILD SUCCESSFUL
Total time: 1.206 secs
Built the following apk(s): /home/matts-pc/Desktop/turn-app/platforms/android/build/outputs/apk/android-debug.apk
ANDROID_HOME=/home/matts-pc/Android/Sdk
JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
Error: android: Command failed with exit code 2`
enter code here
Here is the output when I run cordova run --list
Available android devices:
Available android virtual devices:
ERROR: Error: android: Command failed with exit code 2
An unexpected error has occured while running list-emulator-images with code 2: Error: /home/matts-pc/Desktop/turn-app/platforms/android/cordova/lib/list-emulator-images: Command failed with exit code 2
Let me know if you need anything else! Thank you
Upvotes: 4
Views: 1861
Reputation: 1115
Got an answer from this post !
Inside platforms/android/cordova/lib/emulator.js
:
Change:
return superspawn.spawn('android', ['list', 'avds'])
To:
return superspawn.spawn('android', ['list', 'avd'])
Change:
var command = 'adb -s ' + target + ' install -r "' + apk + '"';
To:
var command = 'adb uninstall "' + pkgName + '"; adb -s ' + target + ' install -r "' + apk + '"';
All credit to the original poster
Upvotes: 4