Providing capabilities for node server from command line

I’m running appium 1.6 from command line on MacOS and I need to provide capabilities.

When I’m running the server, the app is launching but after the logs say that package and activity is incorrect and it terminates after several tries.
So I’m trying to force package and activity name via desiredCapabilities but I need to set the capabilities from the command line, not from the test script. Is it possible?

Can you share the desired capabilities and also the appium and proxy logs

So what I’m doing:

  1. Launch Appium.app (do not start server from .app)
  2. Launch appium server from terminal
  3. Launch inspector from .app

For one application it is working fine, it locates .splash_screen activity and launches the Inspector successfully. For another application it is looking for .splash_screen activity, but locates .main_activity and fails.

In Appium.app I’m only providing path to the application and package, other capabilities are disabled. However, I’ve tried playing with those options as well, to no avail, unfortunately.)

What should I do so that it finds the needed activity or how can I force the activity?

Logs of fail:

[Appium] Welcome to Appium v1.6.0 (REV 2cb385bee15c0ad6aa2e52821a7271c5a6f1b834)
[Appium] Appium REST http interface listener started on 0.0.0.0:4723
[HTTP] --> GET /wd/hub/status {}
[MJSONWP] Calling AppiumDriver.getStatus() with args: []
[MJSONWP] Responding to client with driver.getStatus() result: {"build":{"version":"1.6.0"...
[HTTP] <-- GET /wd/hub/status 200 49 ms - 121 
[HTTP] --> GET /wd/hub/sessions {}
[MJSONWP] Calling AppiumDriver.getSessions() with args: []
[MJSONWP] Responding to client with driver.getSessions() result: []
[HTTP] <-- GET /wd/hub/sessions 200 4 ms - 40 
[HTTP] --> POST /wd/hub/session {"desiredCapabilities":{"platformName":"Android","appPackage":"com.tcs.marathonproduct_dev","newCommandTimeout":"7200","app":"/Users/sergei/Desktop/1246702 Sergio/AutomationLearnings/Appium/MyAppiumWorkspace/MarathonProduct2016/apk/marathonproduct1.3.apk","platformVersion":"4.4","deviceName":"TestingTeamS4","automationName":"Appium"}}
[MJSONWP] Calling AppiumDriver.createSession() with args: [{"platformName":"Android",...
[Appium] Creating new AndroidDriver session
[Appium] Capabilities:
[Appium]   platformName: 'Android'
[Appium]   appPackage: 'com.tcs.marathonproduct_dev'
[Appium]   newCommandTimeout: '7200'
[Appium]   app: '/Users/sergei/Desktop/1246702 Sergio/AutomationLearnings/Appium/MyAppiumWorkspace/MarathonProduct2016/apk/marathonproduct1.3.apk'
[Appium]   platformVersion: '4.4'
[Appium]   deviceName: 'TestingTeamS4'
[Appium]   automationName: 'Appium'
[BaseDriver] Capability 'newCommandTimeout' changed from string ('7200') to integer (7200). This may cause unexpected behavior
[BaseDriver] Session created with session id: 85c6c960-b981-4bd8-8727-fa9bfd3f7206
[debug] [AndroidDriver] Getting Java version
[AndroidDriver] Java version is: 1.8.0_112
[ADB] Checking whether adb is present
[ADB] Using adb from /Users/sergei/Library/Android/sdk/platform-tools/adb
[AndroidDriver] Retrieving device list
[debug] [ADB] Trying to find a connected android device
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[AndroidDriver] Looking for a device with Android '4.4'
[debug] [ADB] Setting device id to 4d00d508d15d4053
[ADB] Getting device platform version
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running '/Users/sergei/Library/Android/sdk/platform-tools/adb' with args: ["-P",5037,"-s","4d00d508d15d4053","shell","getprop","ro.build.version.release"]
[AndroidDriver] Using device: 4d00d508d15d4053
[ADB] Checking whether adb is present
[ADB] Using adb from /Users/sergei/Library/Android/sdk/platform-tools/adb
[debug] [ADB] Setting device id to 4d00d508d15d4053
[BaseDriver] Using local app '/Users/sergei/Desktop/1246702 Sergio/AutomationLearnings/Appium/MyAppiumWorkspace/MarathonProduct2016/apk/marathonproduct1.3.apk'
[debug] [AndroidDriver] Checking whether app is actually present
[AndroidDriver] Starting Android session
[debug] [ADB] Running '/Users/sergei/Library/Android/sdk/platform-tools/adb' with args: ["-P",5037,"-s","4d00d508d15d4053","wait-for-device"]
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running '/Users/sergei/Library/Android/sdk/platform-tools/adb' with args: ["-P",5037,"-s","4d00d508d15d4053","shell","echo","ping"]
[debug] [Logcat] Starting logcat capture
[debug] [AndroidDriver] Pushing settings apk to device...
[debug] [ADB] Running '/Users/sergei/Library/Android/sdk/platform-tools/adb' with args: ["-P",5037,"-s","4d00d508d15d4053","install","/usr/local/lib/node_modules/appium/node_modules/io.appium.settings/bin/settings_apk-debug.apk"]
[debug] [AndroidDriver] Pushing unlock helper app to device...
[debug] [ADB] Running '/Users/sergei/Library/Android/sdk/platform-tools/adb' with args: ["-P",5037,"-s","4d00d508d15d4053","install","/usr/local/lib/node_modules/appium/node_modules/appium-unlock/bin/unlock_apk-debug.apk"]
[ADB] Getting device platform version
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running '/Users/sergei/Library/Android/sdk/platform-tools/adb' with args: ["-P",5037,"-s","4d00d508d15d4053","shell","getprop","ro.build.version.release"]
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running '/Users/sergei/Library/Android/sdk/platform-tools/adb' with args: ["-P",5037,"-s","4d00d508d15d4053","shell","dumpsys","window"]
[AndroidDriver] Screen already unlocked, doing nothing
[debug] [AndroidDriver] Parsing package and activity from app manifest
[ADB] Checking whether aapt is present
[ADB] Using aapt from /Users/sergei/Library/Android/sdk/build-tools/25.0.0/aapt
[ADB] Extracting package and launch activity from manifest
[debug] [ADB] badging package: com.tcs.marathonproduct_dev
[debug] [ADB] badging act: com.tcs.marathonproduct.splash_screen.SplashScreen
[debug] [AndroidDriver] Parsed package and activity are: com.tcs.marathonproduct_dev/com.tcs.marathonproduct.splash_screen.SplashScreen
[AndroidDriver] Remote apk path is /data/local/tmp/2c28778d758b21d8181438460b43e5b2.apk
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running '/Users/sergei/Library/Android/sdk/platform-tools/adb' with args: ["-P",5037,"-s","4d00d508d15d4053","shell","ls","/data/local/tmp/2c28778d758b21d8181438460b43e5b2.apk"]
[debug] [AndroidDriver] Checking if app is installed
[debug] [ADB] Getting install status for com.tcs.marathonproduct_dev
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running '/Users/sergei/Library/Android/sdk/platform-tools/adb' with args: ["-P",5037,"-s","4d00d508d15d4053","shell","getprop","ro.build.version.sdk"]
[debug] [ADB] Device API level: 19
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running '/Users/sergei/Library/Android/sdk/platform-tools/adb' with args: ["-P",5037,"-s","4d00d508d15d4053","shell","pm","list","packages","-3","com.tcs.marathonproduct_dev"]
[debug] [ADB] App is  installed
[AndroidDriver] Apk was already installed but not from our remote path
[AndroidDriver] Reinstalling apk from remote
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running '/Users/sergei/Library/Android/sdk/platform-tools/adb' with args: ["-P",5037,"-s","4d00d508d15d4053","shell","mkdir","-p","/data/local/tmp"]
[AndroidDriver] Clearing out any existing remote apks with the same hash
[debug] [AndroidDriver] Removing any old apks
[debug] [AndroidDriver] Except ["2c28778d758b21d8181438460b43e5b2"]
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running '/Users/sergei/Library/Android/sdk/platform-tools/adb' with args: ["-P",5037,"-s","4d00d508d15d4053","shell","ls","/data/local/tmp/*.apk"]
[AndroidDriver] Will remove /data/local/tmp/fcc3b0b16a110ffeee24cde93273178c.apk
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running '/Users/sergei/Library/Android/sdk/platform-tools/adb' with args: ["-P",5037,"-s","4d00d508d15d4053","shell","rm","-f","/data/local/tmp/fcc3b0b16a110ffeee24cde93273178c.apk"]
[AndroidDriver] Pushing com.tcs.marathonproduct_dev to device. Will wait up to 90000 milliseconds before aborting
[debug] [ADB] Running '/Users/sergei/Library/Android/sdk/platform-tools/adb' with args: ["-P",5037,"-s","4d00d508d15d4053","push","/Users/sergei/Desktop/1246702 Sergio/AutomationLearnings/Appium/MyAppiumWorkspace/MarathonProduct2016/apk/marathonproduct1.3.apk","/data/local/tmp/2c28778d758b21d8181438460b43e5b2.apk"]
[debug] [ADB] Uninstalling com.tcs.marathonproduct_dev
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running '/Users/sergei/Library/Android/sdk/platform-tools/adb' with args: ["-P",5037,"-s","4d00d508d15d4053","shell","am","force-stop","com.tcs.marathonproduct_dev"]
[debug] [ADB] Running '/Users/sergei/Library/Android/sdk/platform-tools/adb' with args: ["-P",5037,"-s","4d00d508d15d4053","uninstall","com.tcs.marathonproduct_dev"]
[ADB] App was uninstalled
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running '/Users/sergei/Library/Android/sdk/platform-tools/adb' with args: ["-P",5037,"-s","4d00d508d15d4053","shell","pm","install","-r","/data/local/tmp/2c28778d758b21d8181438460b43e5b2.apk"]
[debug] [AndroidDriver] Extracting strings from apk /Users/sergei/Desktop/1246702 Sergio/AutomationLearnings/Appium/MyAppiumWorkspace/MarathonProduct2016/apk/marathonproduct1.3.apk null /var/folders/xb/b0vc33zx3y1_jlk8z7psfynr0000gr/T/com.tcs.marathonproduct_dev
[debug] [ADB] Extracting strings for language: default
[debug] [ADB] Device API level: 19
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running '/Users/sergei/Library/Android/sdk/platform-tools/adb' with args: ["-P",5037,"-s","4d00d508d15d4053","shell","getprop","persist.sys.language"]
[debug] [ADB] Current device property 'persist.sys.language': en
[debug] [ADB] No strings.xml for language 'en', getting default strings.xml
[debug] [ADB] Reading strings from converted strings.json
[debug] [ADB] Running '/Users/sergei/Library/Android/sdk/platform-tools/adb' with args: ["-P",5037,"-s","4d00d508d15d4053","push","/var/folders/xb/b0vc33zx3y1_jlk8z7psfynr0000gr/T/com.tcs.marathonproduct_dev/strings.json","/data/local/tmp"]
[debug] [AndroidBootstrap] Watching for bootstrap disconnect
[debug] [ADB] Forwarding system: 4724 to device: 4724
[debug] [ADB] Running '/Users/sergei/Library/Android/sdk/platform-tools/adb' with args: ["-P",5037,"-s","4d00d508d15d4053","forward","tcp:4724","tcp:4724"]
[debug] [UiAutomator] Starting UiAutomator
[debug] [UiAutomator] Moving to state 'starting'
[debug] [UiAutomator] Parsing uiautomator jar
[debug] [UiAutomator] Found jar name: 'AppiumBootstrap.jar'
[debug] [ADB] Running '/Users/sergei/Library/Android/sdk/platform-tools/adb' with args: ["-P",5037,"-s","4d00d508d15d4053","push","/usr/local/lib/node_modules/appium/node_modules/appium-android-bootstrap/bootstrap/bin/AppiumBootstrap.jar","/data/local/tmp/"]
[debug] [ADB] Attempting to kill all uiautomator processes
[debug] [ADB] Getting all processes with uiautomator
[debug] [ADB] Getting connected devices...
[ADB] Error: Unable to get pids for uiautomator. Orginial error: this.shell(...).trim is not a function
    at Object.wrappedLogger.errorAndThrow (lib/logger.js:60:13)
    at ADB.callee$0$0$ (lib/tools/adb-commands.js:441:9)
    at tryCatch (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40)
    at GeneratorFunctionPrototype.invoke [as _invoke] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:315:22)
    at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)
    at invoke (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37)
    at enqueueResult (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:185:17)
    at Promise.F (/usr/local/lib/node_modules/appium/node_modules/core-js/library/modules/$.export.js:30:36)
    at AsyncIterator.enqueue (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:184:12)
    at AsyncIterator.prototype.(anonymous function) [as next] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)
    at Object.runtime.async (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:209:12)
    at ADB.callee$0$0 [as getPIDsByName] (lib/tools/adb-commands.js:431:18)
    at ADB.callee$0$0$ (lib/tools/adb-commands.js:448:27)
    at tryCatch (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40)
    at GeneratorFunctionPrototype.invoke [as _invoke] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:315:22)
    at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)
    at invoke (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37)
    at enqueueResult (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:185:17)
    at Promise.F (/usr/local/lib/node_modules/appium/node_modules/core-js/library/modules/$.export.js:30:36)
    at AsyncIterator.enqueue (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:184:12)
    at AsyncIterator.prototype.(anonymous function) [as next] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)
    at Object.runtime.async (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:209:12)
    at ADB.callee$0$0 [as killProcessesByName] (lib/tools/adb-commands.js:453:17)
    at UiAutomator.killUiAutomatorOnDevice$ (lib/uiautomator.js:90:22)
    at tryCatch (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40)
    at GeneratorFunctionPrototype.invoke [as _invoke] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:315:22)
    at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)
    at invoke (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37)
    at enqueueResult (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:185:17)
    at Promise.F (/usr/local/lib/node_modules/appium/node_modules/core-js/library/modules/$.export.js:30:36)
    at AsyncIterator.enqueue (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:184:12)
    at AsyncIterator.prototype.(anonymous function) [as next] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)
    at Object.runtime.async (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:209:12)
    at UiAutomator.killUiAutomatorOnDevice (lib/uiautomator.js:88:33)
    at UiAutomator.start$ (lib/uiautomator.js:29:18)
    at tryCatch (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40)
    at GeneratorFunctionPrototype.invoke [as _invoke] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:315:22)
    at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)
    at GeneratorFunctionPrototype.invoke (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37)
    at process._tickCallback (internal/process/next_tick.js:103:7)
 Error: Unable to get pids for uiautomator. Orginial error: this.shell(...).trim is not a function
    at Object.wrappedLogger.errorAndThrow (lib/logger.js:60:13)
    at ADB.callee$0$0$ (lib/tools/adb-commands.js:441:9)
    at tryCatch (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40)
    at GeneratorFunctionPrototype.invoke [as _invoke] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:315:22)
    at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)
    at invoke (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37)
    at enqueueResult (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:185:17)
    at Promise.F (/usr/local/lib/node_modules/appium/node_modules/core-js/library/modules/$.export.js:30:36)
    at AsyncIterator.enqueue (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:184:12)
    at AsyncIterator.prototype.(anonymous function) [as next] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)
    at Object.runtime.async (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:209:12)
    at ADB.callee$0$0 [as getPIDsByName] (lib/tools/adb-commands.js:431:18)
    at ADB.callee$0$0$ (lib/tools/adb-commands.js:448:27)
    at tryCatch (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40)
    at GeneratorFunctionPrototype.invoke [as _invoke] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:315:22)
    at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)
    at invoke (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37)
    at enqueueResult (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:185:17)
    at Promise.F (/usr/local/lib/node_modules/appium/node_modules/core-js/library/modules/$.export.js:30:36)
    at AsyncIterator.enqueue (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:184:12)
    at AsyncIterator.prototype.(anonymous function) [as next] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)
    at Object.runtime.async (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:209:12)
    at ADB.callee$0$0 [as killProcessesByName] (lib/tools/adb-commands.js:453:17)
    at UiAutomator.killUiAutomatorOnDevice$ (lib/uiautomator.js:90:22)
    at tryCatch (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40)
    at GeneratorFunctionPrototype.invoke [as _invoke] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:315:22)
    at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)
    at invoke (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37)
    at enqueueResult (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:185:17)
    at Promise.F (/usr/local/lib/node_modules/appium/node_modules/core-js/library/modules/$.export.js:30:36)
    at AsyncIterator.enqueue (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:184:12)
    at AsyncIterator.prototype.(anonymous function) [as next] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)
    at Object.runtime.async (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:209:12)
    at UiAutomator.killUiAutomatorOnDevice (lib/uiautomator.js:88:33)
    at UiAutomator.start$ (lib/uiautomator.js:29:18)
    at tryCatch (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40)
    at GeneratorFunctionPrototype.invoke [as _invoke] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:315:22)
    at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)
    at GeneratorFunctionPrototype.invoke (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37)
    at process._tickCallback (internal/process/next_tick.js:103:7)
[ADB] Error: Unable to kill uiautomator processes. Original error: Unable to get pids for uiautomator. Orginial error: this.shell(...).trim is not a function
    at Object.wrappedLogger.errorAndThrow (lib/logger.js:60:13)
    at ADB.callee$0$0$ (lib/tools/adb-commands.js:457:9)
    at tryCatch (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40)
    at GeneratorFunctionPrototype.invoke [as _invoke] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:315:22)
    at GeneratorFunctionPrototype.prototype.(anonymous function) [as throw] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)
    at GeneratorFunctionPrototype.invoke (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37)
    at process._tickCallback (internal/process/next_tick.js:103:7)
 Error: Unable to kill uiautomator processes. Original error: Unable to get pids for uiautomator. Orginial error: this.shell(...).trim is not a function
    at Object.wrappedLogger.errorAndThrow (lib/logger.js:60:13)
    at ADB.callee$0$0$ (lib/tools/adb-commands.js:457:9)
    at tryCatch (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40)
    at GeneratorFunctionPrototype.invoke [as _invoke] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:315:22)
    at GeneratorFunctionPrototype.prototype.(anonymous function) [as throw] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)
    at GeneratorFunctionPrototype.invoke (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37)
    at process._tickCallback (internal/process/next_tick.js:103:7)
[UiAutomator] Error while killing uiAutomator: Error: Unable to kill uiautomator processes. Original error: Unable to get pids for uiautomator. Orginial error: this.shell(...).trim is not a function
[debug] [UiAutomator] Starting UIAutomator
[debug] [ADB] Creating ADB subprocess with args: -P, 5037, -s, 4d00d508d15d4053, shell, uiautomator, runtest, AppiumBootstrap.jar, -c, io.appium.android.bootstrap.Bootstrap, -e, pkg, com.tcs.marathonproduct_dev, -e, disableAndroidWatchers, false, -e, acceptSslCerts, false
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running '/Users/sergei/Library/Android/sdk/platform-tools/adb' with args: ["-P",5037,"-s","4d00d508d15d4053","shell","ps"]
[debug] [UiAutomator] Moving to state 'online'
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Loading json...
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] json loading complete.
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Registered crash watchers.
[AndroidBootstrap] Android bootstrap socket is now connected
[debug] [ADB] Device API level: 19
[debug] [ADB] Getting connected devices...
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Client connected
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running '/Users/sergei/Library/Android/sdk/platform-tools/adb' with args: ["-P",5037,"-s","4d00d508d15d4053","shell","am","start","-W","-n","com.tcs.marathonproduct_dev/com.tcs.marathonproduct.splash_screen.SplashScreen","-S","-a","android.intent.action.MAIN","-c","android.intent.category.LAUNCHER","-f","0x10200000"]
[debug] [ADB] Waiting for pkg: 'com.tcs.marathonproduct_dev' and activity: 'com.tcs.marathonproduct.splash_screen.SplashScreen' to be focused
[debug] [ADB] Possible activities, to be checked: com.tcs.marathonproduct.splash_screen.SplashScreen, .com.tcs.marathonproduct.splash_screen.SplashScreen
[debug] [ADB] Getting focused package and activity
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running '/Users/sergei/Library/Android/sdk/platform-tools/adb' with args: ["-P",5037,"-s","4d00d508d15d4053","shell","dumpsys","window","windows"]
[debug] [ADB] Found package: 'com.tcs.marathonproduct_dev' and activity: 'com.tcs.marathonproduct.global_common.mainactivity.MainActivity'
[debug] [ADB] Incorrect package and activity. Retrying.
[debug] [ADB] Getting focused package and activity
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running '/Users/sergei/Library/Android/sdk/platform-tools/adb' with args: ["-P",5037,"-s","4d00d508d15d4053","shell","dumpsys","window","windows"]
[debug] [ADB] Found package: 'com.tcs.marathonproduct_dev' and activity: 'com.tcs.marathonproduct.global_common.mainactivity.MainActivity'
[debug] [ADB] Incorrect package and activity. Retrying.

For the shell(…) error, it helped me to install node6 and then install Appium:

brew install [email protected]
brew switch node6-lts 6.9.1

and then (in recent appium-adb there is a fix for that shell(…).trim() issue:

npm install -g appium-adb
brew switch appium-adb 2.6.19

At the end install Appium with changed dependencies (–no-shrinkwrap) - it will use then appium-adb in version 2.6.19 and not the one which is linked by default (2.6.17):

npm install -g appium --no-shrinkwrap