简体   繁体   English

离子模拟 Android 错误 - 退出代码 2

[英]Ionic Emulate Android Error - Exit Code 2

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 .我收到一条错误消息,内容为Error: android: Command failed with exit code 2 But, it does say BUILD SUCCESSFUL .但是,它确实说BUILD SUCCESSFUL


What I'm running我在跑什么

  1. Ubuntu 16.04.2 Ubuntu 16.04.2
  2. Node 6.10.2节点 6.10.2
  3. NPM 3.10.10 NPM 3.10.10
  4. Ionic 2.2.3离子 2.2.3
  5. Cordova 6.5.0科尔多瓦 6.5.0
  6. Android Studio 2.3.1安卓工作室 2.3.1

I have set up environment variables in my .bashrc:我已经在我的 .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这是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这是我运行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谢谢

Got an answer from this post !从这篇文章中得到了答案!

Inside platforms/android/cordova/lib/emulator.js :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所有功劳归功于原始海报

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM