Cannot unlock helper app for Galaxy S5 phone when start Appium programmatically

I wrote a simple test program for the phone connected to my Windows 10 Dell laptop:

    private AndroidDriver driver = null;

@Before
public void setUp() throws MalformedURLException, Exception
{
	appiumStop();
	appiumStart();
	DesiredCapabilities capabilities = new DesiredCapabilities();
	capabilities.setCapability("automationName", System.getProperty("automationName"));
	capabilities.setCapability("platformName", "Android");
	capabilities.setCapability("platformVersion", System.getProperty("platformVersion"));
	capabilities.setCapability("deviceName", "ee29d84f");
	capabilities.setCapability("appPackage", "com.mobeta.android.demodslv");
	capabilities.setCapability("appActivity", ".Launcher");

	driver = new AndroidDriver(new URL("http://0.0.0.0:4723/wd/hub"), capabilities);
	driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);
}


where to start Appium programmatically I use

private Process p;
private String nodePath = "\"C:/Program Files (x86)/Appium/node.exe\""; 
private String appiumJSPath = "\"C:/Program Files (x86)/Appium/node_modules/appium/bin/appium.js\"";		
private String log = "--log \"c:/Program Files (x86)/Appium/log.txt\"";			
private String cmd = nodePath + " " + appiumJSPath + " " + log;

protected void appiumStart() throws IOException, InterruptedException
{ 
	System.out.println(cmd);
	p = Runtime.getRuntime().exec(cmd);
	Thread.sleep(20000);
	int i = 0;
	
	while (p == null && i < 30)
	{
		Thread.sleep(1000);
		i++;
	}

	if (p != null) 
		 System.out.println("Appium server started."); 
	else
		System.out.println("Cannot start Appium server.");
} 

When I start Appium manually the program works fine. When I do it programmatically, it hangs without any errors. I use Appium 1.4.16.1.
Here is the log file.

2016-03-03 19:20:45:389 - info: Welcome to Appium v1.4.16 (REV ae6877eff263066b26328d457bd285c0cc62430d)
2016-03-03 19:20:45:389 - info: Appium REST http interface listener started on 0.0.0.0:4723
2016-03-03 19:20:45:389 - info: [debug] Non-default server args: {“log”:“c:/Program Files (x86)/Appium/log.txt”}
2016-03-03 19:20:45:389 - info: Console LogLevel: debug
2016-03-03 19:20:45:389 - info: File LogLevel: debug
2016-03-03 19:20:54:562 - info: --> POST /wd/hub/session {“desiredCapabilities”:{“appPackage”:“com.mobeta.android.demodslv”,“appActivity”:".Launcher",“platformVersion”:“5.0”,“automationName”:“Appium”,“platformName”:“Android”,“deviceName”:“ee29d84f”}}
2016-03-03 19:20:54:562 - info: Client User-Agent string: Apache-HttpClient/4.3.3 (java 1.5)
2016-03-03 19:20:54:562 - info: [debug] Didn’t get app but did get Android package, will attempt to launch it on the device
2016-03-03 19:20:54:562 - info: [debug] Creating new appium session 0f6508b5-1d01-448a-91a0-74a3bc1d3d3a
2016-03-03 19:20:54:562 - info: Starting android appium
2016-03-03 19:20:54:562 - info: [debug] Getting Java version
2016-03-03 19:20:54:823 - info: Java version is: 1.8.0_65
2016-03-03 19:20:54:823 - info: [debug] Checking whether adb is present
2016-03-03 19:20:54:823 - info: [debug] Using adb from C:\Program Files (x86)\Android\android-sdk\platform-tools\adb.exe
2016-03-03 19:20:54:823 - warn: No app capability, can’t parse package/activity
2016-03-03 19:20:54:823 - info: [debug] Using fast reset? true
2016-03-03 19:20:54:823 - info: [debug] Preparing device for session
2016-03-03 19:20:54:823 - info: [debug] Not checking whether app is present since we are assuming it’s already on the device
2016-03-03 19:20:54:823 - info: Retrieving device
2016-03-03 19:20:54:823 - info: [debug] Trying to find a connected android device
2016-03-03 19:20:54:823 - info: [debug] Getting connected devices…
2016-03-03 19:20:54:823 - info: [debug] executing cmd: “C:\Program Files (x86)\Android\android-sdk\platform-tools\adb.exe” devices
2016-03-03 19:20:59:165 - info: [debug] 1 device(s) connected
2016-03-03 19:20:59:165 - info: Found device ee29d84f
2016-03-03 19:20:59:165 - info: [debug] Setting device id to ee29d84f
2016-03-03 19:20:59:165 - info: [debug] Waiting for device to be ready and to respond to shell commands (timeout = 5)
2016-03-03 19:20:59:181 - info: [debug] executing cmd: “C:\Program Files (x86)\Android\android-sdk\platform-tools\adb.exe” -s ee29d84f wait-for-device
2016-03-03 19:20:59:228 - info: [debug] executing cmd: “C:\Program Files (x86)\Android\android-sdk\platform-tools\adb.exe” -s ee29d84f shell “echo ‘ready’”
2016-03-03 19:20:59:343 - info: [debug] Starting logcat capture
2016-03-03 19:20:59:413 - info: [debug] Getting device API level
2016-03-03 19:20:59:413 - info: [debug] executing cmd: “C:\Program Files (x86)\Android\android-sdk\platform-tools\adb.exe” -s ee29d84f shell “getprop ro.build.version.sdk”
2016-03-03 19:20:59:544 - info: [debug] Device is at API Level 21
2016-03-03 19:20:59:544 - info: Device API level is: 21
2016-03-03 19:20:59:544 - info: [debug] Extracting strings for language: default
2016-03-03 19:20:59:544 - info: [debug] Apk doesn’t exist locally
2016-03-03 19:20:59:544 - info: [debug] Could not get strings, but it looks like we had an old strings file anyway, so ignoring
2016-03-03 19:20:59:544 - info: [debug] executing cmd: “C:\Program Files (x86)\Android\android-sdk\platform-tools\adb.exe” -s ee29d84f shell “rm -rf /data/local/tmp/strings.json”
2016-03-03 19:20:59:597 - info: [debug] Not uninstalling app since server not started with --full-reset
2016-03-03 19:20:59:597 - info: [debug] Skipping install since we launched with a package instead of an app path
2016-03-03 19:20:59:597 - info: [debug] Forwarding system:4724 to device:4724
2016-03-03 19:20:59:597 - info: [debug] executing cmd: “C:\Program Files (x86)\Android\android-sdk\platform-tools\adb.exe” -s ee29d84f forward tcp:4724 tcp:4724
2016-03-03 19:20:59:628 - info: [debug] Pushing appium bootstrap to device…
2016-03-03 19:20:59:628 - info: [debug] executing cmd: “C:\Program Files (x86)\Android\android-sdk\platform-tools\adb.exe” -s ee29d84f push “C:\Program Files (x86)\Appium\node_modules\appium\build\android_bootstrap\AppiumBootstrap.jar” /data/local/tmp/
2016-03-03 19:20:59:728 - info: [debug] Pushing settings apk to device…
2016-03-03 19:20:59:728 - info: [debug] executing cmd: “C:\Program Files (x86)\Android\android-sdk\platform-tools\adb.exe” -s ee29d84f install “C:\Program Files (x86)\Appium\node_modules\appium\build\settings_apk\settings_apk-debug.apk”
2016-03-03 19:21:08:117 - info: [debug] Pushing unlock helper app to device…

Is the programmatic version starting the appium server the same as the manual version? I suspect not as you have to pass the capabilities. Can you show it here as well as the output from when you print out cmd

This line in the appium server logs looks suspicious:

2016-03-03 19:20:54:823 - warn: No app capability, can't parse package/activity

I’m not an appium server expert, it may be just fine.

This is what I have when start Appium server manually

C:\Program Files (x86)\Appium\node_modules>node appium
info: Welcome to Appium v1.4.16 (REV ae6877eff263066b26328d457bd285c0cc62430d)
info: Appium REST http interface listener started on 0.0.0.0:4723
info: Console LogLevel: debug

info: --> POST /wd/hub/session {“desiredCapabilities”:{“appPackage”:“com.mobeta.android.demodslv”,“appActivity”:".Launcher",“platformVersion”:“5.0”,“automationName”:“Appium”,“platformName”:“Android”,“deviceName”:“ee29d84f”}}
info: Client User-Agent string: Apache-HttpClient/4.3.3 (java 1.5)
info: [debug] Didn’t get app but did get Android package, will attempt to launch it on the device
info: [debug] Creating new appium session 64283b7f-49f7-4a38-a925-d01352d272f6
info: Starting android appium
info: [debug] Getting Java version
info: Java version is: 1.8.0_65
info: [debug] Checking whether adb is present
info: [debug] Using adb from C:\Program Files (x86)\Android\android-sdk\platform-tools\adb.exe
warn: No app capability, can’t parse package/activity
info: [debug] Using fast reset? true
info: [debug] Preparing device for session
info: [debug] Not checking whether app is present since we are assuming it’s already on the device
info: Retrieving device
info: [debug] Trying to find a connected android device
info: [debug] Getting connected devices…
info: [debug] executing cmd: “C:\Program Files (x86)\Android\android-sdk\platform-tools\adb.exe” devices
info: [debug] 1 device(s) connected
info: Found device ee29d84f
info: [debug] Setting device id to ee29d84f
info: [debug] Waiting for device to be ready and to respond to shell commands (timeout = 5)
info: [debug] executing cmd: “C:\Program Files (x86)\Android\android-sdk\platform-tools\adb.exe” -s ee29d84f wait-for-device
info: [debug] executing cmd: “C:\Program Files (x86)\Android\android-sdk\platform-tools\adb.exe” -s ee29d84f shell “echo ‘ready’”
info: [debug] Starting logcat capture
info: [debug] Getting device API level
info: [debug] executing cmd: “C:\Program Files (x86)\Android\android-sdk\platform-tools\adb.exe” -s ee29d84f 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] Apk doesn’t exist locally
info: [debug] Could not get strings, but it looks like we had an old strings file anyway, so ignoring
info: [debug] executing cmd: “C:\Program Files (x86)\Android\android-sdk\platform-tools\adb.exe” -s ee29d84f shell “rm -rf /data/local/tmp/strings.json”
info: [debug] Not uninstalling app since server not started with --full-reset
info: [debug] Skipping install since we launched with a package instead of an app path
info: [debug] Forwarding system:4724 to device:4724
info: [debug] executing cmd: “C:\Program Files (x86)\Android\android-sdk\platform-tools\adb.exe” -s ee29d84f forward tcp:4724 tcp:4724
info: [debug] Pushing appium bootstrap to device…
info: [debug] executing cmd: “C:\Program Files (x86)\Android\android-sdk\platform-tools\adb.exe” -s ee29d84f 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:\Program Files (x86)\Android\android-sdk\platform-tools\adb.exe” -s ee29d84f install “C:\Program Files (x86)\Appium\node_modules\appium\build\settings_apk\settings_apk-debug.apk”
info: [debug] Pushing unlock helper app to device…
info: [debug] executing cmd: “C:\Program Files (x86)\Android\android-sdk\platform-tools\adb.exe” -s ee29d84f install “C:\Program Files (x86)\Appium\node_modules\appium\build\unlock_apk\unlock_apk-debug.apk”
info: Starting App
info: [debug] Attempting to kill all ‘uiautomator’ processes
info: [debug] Getting all processes with ‘uiautomator’
info: [debug] executing cmd: “C:\Program Files (x86)\Android\android-sdk\platform-tools\adb.exe” -s ee29d84f shell “ps ‘uiautomator’”
info: [debug] No matching processes found
info: [debug] Running bootstrap
info: [debug] spawning: C:\Program Files (x86)\Android\android-sdk\platform-tools\adb.exe -s ee29d84f shell uiautomator runtest AppiumBootstrap.jar -c io.appium.android.bootstrap.Bootstrap -e pkg com.mobeta.android.demodslv -e disableAndroidWatchers false
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: numtests=1
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: stream=
info: [debug] [UIAUTOMATOR STDOUT] io.appium.android.bootstrap.Bootstrap:
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: id=UiAutomatorTestRunner
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: test=testRunServer
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: class=io.appium.android.bootstrap.Bootstrap
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: current=1
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS_CODE: 1
info: [debug] [BOOTSTRAP] [debug] Socket opened on port 4724
info: [debug] [BOOTSTRAP] [debug] Appium Socket Server Ready
info: [debug] [BOOTSTRAP] [debug] Loading json…
info: [debug] [BOOTSTRAP] [debug] Registered crash watchers.
info: [debug] Waking up device if it’s not alive
info: [debug] Pushing command to appium work queue: [“wake”,{}]
info: [debug] [BOOTSTRAP] [debug] Client connected
info: [debug] [BOOTSTRAP] [debug] Got data from client: {“cmd”:“action”,“action”:“wake”,“params”:{}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: wake
info: [debug] executing cmd: “C:\Program Files (x86)\Android\android-sdk\platform-tools\adb.exe” -s ee29d84f shell “dumpsys window”
info: [debug] [BOOTSTRAP] [debug] Returning result: {“status”:0,“value”:true}
info: [debug] Screen already unlocked, continuing.
info: [debug] Pushing command to appium work queue: [“getDataDir”,{}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {“cmd”:“action”,“action”:“getDataDir”,“params”:{}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: getDataDir
info: [debug] [BOOTSTRAP] [debug] Returning result: {“status”:0,“value”:"/data/local/tmp"}
info: [debug] dataDir set to: /data/local/tmp
info: [debug] Pushing command to appium work queue: [“compressedLayoutHierarchy”,{“compressLayout”:false}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {“cmd”:“action”,“action”:“compressedLayoutHierarchy”,“params”:{“compressLayout”:false}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: compressedLayoutHierarchy
info: [debug] Getting device API level
info: [debug] executing cmd: “C:\Program Files (x86)\Android\android-sdk\platform-tools\adb.exe” -s ee29d84f shell “getprop ro.build.version.sdk”
info: [debug] [BOOTSTRAP] [debug] Returning result: {“status”:0,“value”:false}
info: [debug] Device is at API Level 21
info: [debug] executing cmd: “C:\Program Files (x86)\Android\android-sdk\platform-tools\adb.exe” -s ee29d84f shell “am start -S -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -f 0x10200000 -n com.mobeta.android.demodslv/.Launcher”
info: [debug] Waiting for pkg “com.mobeta.android.demodslv” and activity “.Launcher” to be focused
info: [debug] Getting focused package and activity
info: [debug] executing cmd: “C:\Program Files (x86)\Android\android-sdk\platform-tools\adb.exe” -s ee29d84f shell “dumpsys window windows”
info: [debug] executing cmd: “C:\Program Files (x86)\Android\android-sdk\platform-tools\adb.exe” -s ee29d84f shell “getprop ro.build.version.release”
info: [debug] Device is at release version 5.0
info: [debug] Device launched! Ready for commands
info: [debug] Setting command timeout to the default of 60 secs
info: [debug] Appium session started with sessionId 64283b7f-49f7-4a38-a925-d01352d272f6

Ok, the warning is not fatal. Now I see your title should be “Cannot push unlock helper app…”. I thought you had merely truncated your logs, but presumably the log ends there and you see no other output, is that right?

I don’t see anything different in your capabilities. Have you tried another device? I have had nothing but troubles using automation on the two GS5 devices I’ve worked with. It’s why I won’t use them any more.

Sorry I can’t be of more help

Thank you willoserr for your help. Samsung Galaxy 5 is the only device I have.