[Android] [Windows] Failed to start an Appium session, err was: Error: Command failed:

could anyone please help?

I was trying to run a test case with Appium, but kept seeing this error message …

Failed to start an Appium session, err was: Error: Command failed: C:\win
dows\system32\cmd.exe /s /c “C:\Users\v-dazhen\AppData\Local\Android\sdk\platfor
m-tools\adb.exe -s 06157df65003392f install “C:\Program Files (x86)\Appium\node_
modules\appium\build\settings_apk\settings_apk-debug.apk””

Did some reach online and tried to manually install it with command …

C:\Users\v-dazhen\AppData\Local\Android\sdk\platform-tools\adb.exe -s 06157df65003392f install “C:\Program Files (x86)\Appium\node_modules\appium\build\settings_apk\settings_apk-debug.apk”

then got and error message …
Failure [INSTALL_FAILED_ALREADY_EXISTS]

and a popup dialog box adb.exe saying …
An unhandled win32 exception occurred in adb.exe [2504]

then I tried to uninstall [Appium Settings] from Android phone, and tried above command again, this time the installation succeed, but still got adb.exe crashed.

Platform you are automating - Android
Appium version - 1.4.16.1
Real Device
The language you are using for writing tests (client binding) - C#
Your OS - Windows Server 2012

.
.
.
.
.
.
.
.


C:\Users\v-dazhen\Documents\cfe_sfb_e2e\tools\MobileDeviceManager\bin\Debug>set
UUID=06157df65003392f

C:\Users\v-dazhen\Documents\cfe_sfb_e2e\tools\MobileDeviceManager\bin\Debug>adb.
exe -s 06157df65003392f kill-server

C:\Users\v-dazhen\Documents\cfe_sfb_e2e\tools\MobileDeviceManager\bin\Debug>adb.
exe -s 06157df65003392f wait-for-device

  • daemon not running. starting it now on port 5037 *
  • daemon started successfully *

C:\Users\v-dazhen\Documents\cfe_sfb_e2e\tools\MobileDeviceManager\bin\Debug>adb.
exe -s 06157df65003392f devices
List of devices attached
06157df65003392f device

C:\Users\v-dazhen\Documents\cfe_sfb_e2e\tools\MobileDeviceManager\bin\Debug>adb.
exe -s 06157df65003392f shell “echo ‘ready’”
ready
2016-09-21_17-40-44_17
info: Welcome to Appium v1.4.16 (REV ae6877eff263066b26328d457bd285c0cc62430d)
info: Appium REST http interface listener started on 127.0.0.1:4723
info: [debug] Non-default server args: {“udid”:“06157df65003392f”,“address”:“127
.0.0.1”,“sessionOverride”:true,“noReset”:true,“log”:“C:\Users\v-dazhen\Docume
nts\cfe_sfb_e2e\tools\MobileDeviceManager\bin\Debug\AppiumLog\Appium_2016
-09-21_17-40-44_17.txt”,“androidPackage”:“C:\Users\v-dazhen\Documents\cfe_sf
b_e2e\tools\MobileDeviceManager\bin\Debug\Apps\janus-release-6.8.2.5.apk”,
“deviceName”:“SAMSUNG-SM-G920V”,“platformName”:“Android”,“automationName”:“Appiu
m”}
info: Console LogLevel: debug
info: File LogLevel: debug
info: --> POST /wd/hub/session {“desiredCapabilities”:{“deviceName”:“SAMSUNG-SM-
G920V”,“appPackage”:“com.microsoft.office.sfb.beta”,“app”:“C:\Users\v-dazhen\
Documents\cfe_sfb_e2e\tools\MobileDeviceManager\bin\Debug\Apps\janus-rele
ase-6.8.2.5.apk”,“appWaitActivity”:“com.microsoft.office.sfb.activity.SplashActi
vity”,“newCommandTimeout”:“1230”,“platformName”:“Android”}}
info: Client User-Agent string: undefined
info: [debug] No appActivity desired capability or server param. Parsing from ap
k.
info: [debug] Using local app from desired caps: C:\Users\v-dazhen\Documents\cfe
sfb_e2e\tools\MobileDeviceManager\bin\Debug\Apps\janus-release-6.8.2.5.apk
info: [debug] Creating new appium session 047b08ce-f8d4-4159-8d70-c077f83cd9d0
info: Starting android appium
info: [debug] Getting Java version
info: Java version is: 1.8.0_101
info: [debug] Checking whether adb is present
info: [debug] Using adb from C:\Users\v-dazhen\AppData\Local\Android\sdk\platfor
m-tools\adb.exe
info: [debug] Parsing package and activity from app manifest
info: [debug] Checking whether aapt is present
info: [debug] Using aapt from C:\Users\v-dazhen\AppData\Local\Android\sdk\build-
tools\24.0.2\aapt.exe
info: [debug] Extracting package and launch activity from manifest.
info: [debug] executing cmd: C:\Users\v-dazhen\AppData\Local\Android\sdk\build-t
ools\24.0.2\aapt.exe dump badging C:\Users\v-dazhen\Documents\cfe_sfb_e2e\tools
MobileDeviceManager\bin\Debug\Apps\janus-release-6.8.2.5.apk
info: [debug] badging package: com.microsoft.office.sfb.beta
info: [debug] badging act: com.microsoft.office.sfb.common.ui.splash.EntryPoint
info: [debug] Parsed package and activity are: com.microsoft.office.sfb.beta/com
.microsoft.office.sfb.common.ui.splash.EntryPoint
info: [debug] Using fast reset? false
info: [debug] Preparing device for session
info: [debug] Checking whether app is actually present
info: Retrieving device
info: [debug] Trying to find a connected android device
info: [debug] Getting connected devices…
info: [debug] executing cmd: C:\Users\v-dazhen\AppData\Local\Android\sdk\platfor
m-tools\adb.exe devices
info: [debug] 1 device(s) connected
info: Found device 06157df65003392f
info: [debug] Setting device id to 06157df65003392f
info: [debug] Waiting for device to be ready and to respond to shell commands (t
imeout = 5)
info: [debug] executing cmd: C:\Users\v-dazhen\AppData\Local\Android\sdk\platfor
m-tools\adb.exe -s 06157df65003392f wait-for-device
info: [debug] executing cmd: C:\Users\v-dazhen\AppData\Local\Android\sdk\platfor
m-tools\adb.exe -s 06157df65003392f shell “echo ‘ready’”
info: [debug] Starting logcat capture
info: [debug] Getting device API level
info: [debug] executing cmd: C:\Users\v-dazhen\AppData\Local\Android\sdk\platfor
m-tools\adb.exe -s 06157df65003392f shell “getprop ro.build.version.sdk”
info: [debug] Device is at API Level 21
info: Device API level is: 21
info: [debug] Extracting strings for language: default
info: [debug] executing cmd: C:\Users\v-dazhen\AppData\Local\Android\sdk\platfor
m-tools\adb.exe -s 06157df65003392f shell “getprop persist.sys.language”
info: [debug] Current device persist.sys.language: en
info: [debug] java -jar "C:\Program Files (x86)\Appium\node_modules\appium\node

modules\appium-adb\jars\appium_apk_tools.jar" “stringsFromApk” “C:\Users\v-dazhe
n\Documents\cfe_sfb_e2e\tools\MobileDeviceManager\bin\Debug\Apps\janus-release-6
.8.2.5.apk” “C:\Users\v-dazhen\AppData\Local\Temp\com.microsoft.office.sfb.beta”
en
info: [debug] No strings.xml for language ‘en’, getting default strings.xml
info: [debug] java -jar “C:\Program Files (x86)\Appium\node_modules\appium\node_
modules\appium-adb\jars\appium_apk_tools.jar” “stringsFromApk” “C:\Users\v-dazhe
n\Documents\cfe_sfb_e2e\tools\MobileDeviceManager\bin\Debug\Apps\janus-release-6
.8.2.5.apk” “C:\Users\v-dazhen\AppData\Local\Temp\com.microsoft.office.sfb.beta”

info: [debug] Reading strings from converted strings.json
info: [debug] Setting language to default
info: [debug] executing cmd: C:\Users\v-dazhen\AppData\Local\Android\sdk\platfor
m-tools\adb.exe -s 06157df65003392f push “C:\Users\v-dazhen\AppData\Local\T
emp\com.microsoft.office.sfb.beta\strings.json” /data/local/tmp
info: [debug] Checking whether aapt is present
info: [debug] Using aapt from C:\Users\v-dazhen\AppData\Local\Android\sdk\build-
tools\24.0.2\aapt.exe
info: [debug] Retrieving process from manifest.
info: [debug] executing cmd: C:\Users\v-dazhen\AppData\Local\Android\sdk\build-t
ools\24.0.2\aapt.exe dump xmltree C:\Users\v-dazhen\Documents\cfe_sfb_e2e\tools
MobileDeviceManager\bin\Debug\Apps\janus-release-6.8.2.5.apk AndroidManifest.xml

info: [debug] Set app process to: com.microsoft.office.sfb.beta
info: [debug] Not uninstalling app since server not started with --full-reset
info: [debug] Checking app cert for C:\Users\v-dazhen\Documents\cfe_sfb_e2e\tool
s\MobileDeviceManager\bin\Debug\Apps\janus-release-6.8.2.5.apk.
info: [debug] executing cmd: java -jar “C:\Program Files (x86)\Appium\node_modul
es\appium\node_modules\appium-adb\jars\verify.jar” C:\Users\v-dazhen\Documents\c
fe_sfb_e2e\tools\MobileDeviceManager\bin\Debug\Apps\janus-release-6.8.2.5.apk
info: [debug] App already signed.
info: [debug] Zip-aligning C:\Users\v-dazhen\Documents\cfe_sfb_e2e\tools\MobileD
eviceManager\bin\Debug\Apps\janus-release-6.8.2.5.apk
info: [debug] Checking whether zipalign is present
info: [debug] Using zipalign from C:\Users\v-dazhen\AppData\Local\Android\sdk\bu
ild-tools\24.0.2\zipalign.exe
info: [debug] Zip-aligning apk.
info: [debug] executing cmd: C:\Users\v-dazhen\AppData\Local\Android\sdk\build-t
ools\24.0.2\zipalign.exe -f 4 C:\Users\v-dazhen\Documents\cfe_sfb_e2e\tools\Mobi
leDeviceManager\bin\Debug\Apps\janus-release-6.8.2.5.apk C:\Users\v-dazhen\AppDa
ta\Local\Temp\116821-4556-cflvfz\appium.tmp
info: [debug] MD5 for app is da7a9ffbbfe6f3d92271a6eae0235584
info: [debug] executing cmd: C:\Users\v-dazhen\AppData\Local\Android\sdk\platfor
m-tools\adb.exe -s 06157df65003392f shell “ls /data/local/tmp/da7a9ffbbfe6f3d922
71a6eae0235584.apk”
info: [debug] Getting install status for com.microsoft.office.sfb.beta
info: [debug] Getting device API level
info: [debug] executing cmd: C:\Users\v-dazhen\AppData\Local\Android\sdk\platfor
m-tools\adb.exe -s 06157df65003392f shell “getprop ro.build.version.sdk”
info: [debug] Device is at API Level 21
info: [debug] executing cmd: C:\Users\v-dazhen\AppData\Local\Android\sdk\platfor
m-tools\adb.exe -s 06157df65003392f shell “pm list packages -3 com.microsoft.off
ice.sfb.beta”
info: [debug] App is not installed
info: Installing App
info: [debug] executing cmd: C:\Users\v-dazhen\AppData\Local\Android\sdk\platfor
m-tools\adb.exe -s 06157df65003392f shell “mkdir -p /data/local/tmp/”
info: [debug] Removing any old apks
info: [debug] executing cmd: C:\Users\v-dazhen\AppData\Local\Android\sdk\platfor
m-tools\adb.exe -s 06157df65003392f shell “ls /data/local/tmp/*.apk”
info: [debug] Found an apk we want to keep at /data/local/tmp/da7a9ffbbfe6f3d922
71a6eae0235584.apk
info: [debug] Couldn’t find any apks to remove
info: [debug] Uninstalling com.microsoft.office.sfb.beta
info: [debug] executing cmd: C:\Users\v-dazhen\AppData\Local\Android\sdk\platfor
m-tools\adb.exe -s 06157df65003392f shell “am force-stop com.microsoft.office.sf
b.beta”
info: [debug] executing cmd: C:\Users\v-dazhen\AppData\Local\Android\sdk\platfor
m-tools\adb.exe -s 06157df65003392f uninstall com.microsoft.office.sfb.beta
info: [debug] App was not uninstalled, maybe it wasn’t on device?
info: [debug] executing cmd: C:\Users\v-dazhen\AppData\Local\Android\sdk\platfor
m-tools\adb.exe -s 06157df65003392f shell “pm install -r /data/local/tmp/da7a9ff
bbfe6f3d92271a6eae0235584.apk”
info: [debug] Forwarding system:4724 to device:4724
info: [debug] executing cmd: C:\Users\v-dazhen\AppData\Local\Android\sdk\platfor
m-tools\adb.exe -s 06157df65003392f forward tcp:4724 tcp:4724
info: [debug] Pushing appium bootstrap to device…
info: [debug] executing cmd: C:\Users\v-dazhen\AppData\Local\Android\sdk\platfor
m-tools\adb.exe -s 06157df65003392f push “C:\Program Files (x86)\Appium\node_
modules\appium\build\android_bootstrap\AppiumBootstrap.jar” /data/local/tmp/

info: [debug] Pushing settings apk to device…
info: [debug] executing cmd: C:\Users\v-dazhen\AppData\Local\Android\sdk\platfor
m-tools\adb.exe -s 06157df65003392f install “C:\Program Files (x86)\Appium\node_
modules\appium\build\settings_apk\settings_apk-debug.apk”
info: [debug] Stopping logcat capture
info: [debug] Logcat terminated with code null, signal SIGTERM
info: [debug] Sent shutdown command, waiting for UiAutomator to stop…
warn: UiAutomator did not shut down fast enough, calling it gone
info: [debug] Cleaning up android objects
info: [debug] Cleaning up appium session
error: Failed to start an Appium session, err was: Error: Command failed: C:\win
dows\system32\cmd.exe /s /c “C:\Users\v-dazhen\AppData\Local\Android\sdk\platfor
m-tools\adb.exe -s 06157df65003392f install “C:\Program Files (x86)\Appium\node_
modules\appium\build\settings_apk\settings_apk-debug.apk””

info: [debug] Error: Command failed: C:\windows\system32\cmd.exe /s /c “C:\Users
\v-dazhen\AppData\Local\Android\sdk\platform-tools\adb.exe -s 06157df65003392f i
nstall “C:\Program Files (x86)\Appium\node_modules\appium\build\settings_apk\set
tings_apk-debug.apk””

at ChildProcess.exithandler (child_process.js:751:12)
at ChildProcess.emit (events.js:110:17)
at maybeClose (child_process.js:1016:16)
at Process.ChildProcess._handle.onexit (child_process.js:1088:5)

info: [debug] Responding to client with error: {“status”:33,“value”:{“message”:"
A new session could not be created. (Original error: Command failed: C:\windows
\system32\cmd.exe /s /c “C:\Users\v-dazhen\AppData\Local\Android\sdk\p
latform-tools\adb.exe -s 06157df65003392f install “C:\Program Files (x86)\Ap
pium\node_modules\appium\build\settings_apk\settings_apk-debug.apk””\n)",
“killed”:false,“code”:3221226356,“signal”:null,“cmd”:“C:\windows\system32\cmd
.exe /s /c “C:\Users\v-dazhen\AppData\Local\Android\sdk\platform-tools\
adb.exe -s 06157df65003392f install “C:\Program Files (x86)\Appium\node_modu
les\appium\build\settings_apk\settings_apk-debug.apk”””,“origValue”:“Comma
nd failed: C:\windows\system32\cmd.exe /s /c “C:\Users\v-dazhen\AppData\
Local\Android\sdk\platform-tools\adb.exe -s 06157df65003392f install “C:\P
rogram Files (x86)\Appium\node_modules\appium\build\settings_apk\settings_
apk-debug.apk””\n”},“sessionId”:null}
info: <-- POST /wd/hub/session 500 31106.531 ms - 952

I also have same issue appreciate help on this