Error: Screen did not unlock

Hi,

Any update on this: https://github.com/appium/appium/issues/1401

I was asked to make tests to take screenshots on headless machine. So I’m using android emulator with -no-audio and -no-window parameters. But when its launching the tests I get the error:

 Error: Screen did not unlock
Please ignore the [36minfoe[39m on front of logs

[36minfoe[39m: Welcome to Appium v1.2.2 (REV cf6ff5939ddc6b4d45fcbabfbfe13c950e0058c4)
e[36minfoe[39m: Appium REST http interface listener started on 0.0.0.0:4720
e[36minfoe[39m: [debug] Non-default server args: {“port”:4720}
e[36minfoe[39m: LogLevel: debug
e[36minfoe[39m: e[37m–>e[39m e[37mPOSTe[39m e[37m/wd/hub/sessione[39m e[90m{“desiredCapabilities”:{“platformName”:“android”,“app”:"/Users/wcs_mac/Desktop/appium/headless/note.apk",“deviceName”:“Android Emulator”}}e[39m
e[36minfoe[39m: [debug] No appActivity desired capability or server param. Parsing from apk.
e[36minfoe[39m: [debug] No appPackage desired capability or server param. Parsing from apk.
e[36minfoe[39m: [debug] Using local app from desired caps: /Users/wcs_mac/Desktop/appium/headless/note.apk
e[36minfoe[39m: [debug] Creating new appium session 2afe8b9e-103a-4dce-9660-22a5888f8a1d
e[36minfoe[39m: Starting android appium
e[36minfoe[39m: [debug] Using fast reset? true
e[36minfoe[39m: [debug] Preparing device for session
e[36minfoe[39m: [debug] Checking whether app is actually present
e[36minfoe[39m: [debug] Checking whether adb is present
e[36minfoe[39m: [debug] Using adb from /Users/wcs_mac/Desktop/appium/sdk/sdk/platform-tools/adb
e[36minfoe[39m: Retrieving device
e[36minfoe[39m: [debug] Trying to find a connected android device
e[36minfoe[39m: [debug] Getting connected devices…
e[36minfoe[39m: [debug] executing: “/Users/wcs_mac/Desktop/appium/sdk/sdk/platform-tools/adb” devices
e[36minfoe[39m: [debug] 0 device(s) connected
e[36minfoe[39m: [debug] Could not find devices, restarting adb server…
e[36minfoe[39m: [debug] executing: “/Users/wcs_mac/Desktop/appium/sdk/sdk/platform-tools/adb” kill-server
e[36minfoe[39m: [debug] Getting connected devices…
e[36minfoe[39m: [debug] executing: “/Users/wcs_mac/Desktop/appium/sdk/sdk/platform-tools/adb” devices
e[36minfoe[39m: [debug] 1 device(s) connected
e[36minfoe[39m: Found device emulator-5554
e[36minfoe[39m: [debug] Setting device id to emulator-5554
e[36minfoe[39m: [debug] Waiting for device to be ready and to respond to shell commands (timeout = 5)
e[36minfoe[39m: [debug] executing: “/Users/wcs_mac/Desktop/appium/sdk/sdk/platform-tools/adb” -s emulator-5554 wait-for-device
e[36minfoe[39m: [debug] executing: “/Users/wcs_mac/Desktop/appium/sdk/sdk/platform-tools/adb” -s emulator-5554 shell “echo ‘ready’”
e[36minfoe[39m: [debug] Starting logcat capture
e[36minfoe[39m: [debug] Parsing package and activity from app manifest
e[36minfoe[39m: [debug] Checking whether aapt is present
e[36minfoe[39m: [debug] Using aapt from /Users/wcs_mac/Desktop/appium/sdk/sdk/build-tools/android-4.4W/aapt
e[36minfoe[39m: [debug] packageAndLaunchActivityFromManifest: “/Users/wcs_mac/Desktop/appium/sdk/sdk/build-tools/android-4.4W/aapt” dump badging /Users/wcs_mac/Desktop/appium/headless/note.apk
e[36minfoe[39m: [debug] badging package: com.flufflydelusions.app.enotesclassiclite
e[36minfoe[39m: [debug] badging act: com.flufflydelusions.app.enotesclassiclite.Notepadv3
e[36minfoe[39m: [debug] Parsed package and activity are: com.flufflydelusions.app.enotesclassiclite/com.flufflydelusions.app.enotesclassiclite.Notepadv3
e[36minfoe[39m: [debug] Getting device API level
e[36minfoe[39m: [debug] executing: “/Users/wcs_mac/Desktop/appium/sdk/sdk/platform-tools/adb” -s emulator-5554 shell “getprop ro.build.version.sdk”
e[36minfoe[39m: [debug] Device is at API Level 19
e[36minfoe[39m: Device API level is: 19
e[36minfoe[39m: [debug] executing: “/Users/wcs_mac/Desktop/appium/sdk/sdk/platform-tools/adb” -s emulator-5554 shell “getprop persist.sys.language”
e[36minfoe[39m: [debug] Current device language: en
e[36minfoe[39m: [debug] java -jar “/usr/local/lib/node_modules/appium/node_modules/appium-adb/jars/appium_apk_tools.jar” “stringsFromApk” “/Users/wcs_mac/Desktop/appium/headless/note.apk” “/tmp/com.flufflydelusions.app.enotesclassiclite” en
e[36minfoe[39m: [debug] No strings.xml for language ‘en’, getting default strings.xml
e[36minfoe[39m: [debug] java -jar “/usr/local/lib/node_modules/appium/node_modules/appium-adb/jars/appium_apk_tools.jar” “stringsFromApk” “/Users/wcs_mac/Desktop/appium/headless/note.apk” “/tmp/com.flufflydelusions.app.enotesclassiclite”
e[36minfoe[39m: [debug] executing: “/Users/wcs_mac/Desktop/appium/sdk/sdk/platform-tools/adb” -s emulator-5554 push “/tmp/com.flufflydelusions.app.enotesclassiclite/strings.json” /data/local/tmp
e[36minfoe[39m: [debug] Checking whether aapt is present
e[36minfoe[39m: [debug] Using aapt from /Users/wcs_mac/Desktop/appium/sdk/sdk/build-tools/android-4.4W/aapt
e[36minfoe[39m: [debug] processFromManifest: “/Users/wcs_mac/Desktop/appium/sdk/sdk/build-tools/android-4.4W/aapt” dump xmltree “/Users/wcs_mac/Desktop/appium/headless/note.apk” AndroidManifest.xml
e[36minfoe[39m: [debug] Set app process to: com.flufflydelusions.app.enotesclassiclite
e[36minfoe[39m: [debug] Not uninstalling app since server not started with --full-reset
e[36minfoe[39m: [debug] Checking app cert for /Users/wcs_mac/Desktop/appium/headless/note.apk: java -jar “/usr/local/lib/node_modules/appium/node_modules/appium-adb/jars/verify.jar” “/Users/wcs_mac/Desktop/appium/headless/note.apk”
e[36minfoe[39m: [debug] App already signed.
e[36minfoe[39m: [debug] Zip-aligning /Users/wcs_mac/Desktop/appium/headless/note.apk
e[36minfoe[39m: [debug] Checking whether zipalign is present
e[36minfoe[39m: [debug] Using zipalign from /Users/wcs_mac/Desktop/appium/sdk/sdk/build-tools/android-4.4W/zipalign
e[36minfoe[39m: [debug] zipAlignApk: “/Users/wcs_mac/Desktop/appium/sdk/sdk/build-tools/android-4.4W/zipalign” -f 4 “/Users/wcs_mac/Desktop/appium/headless/note.apk” “/var/folders/jg/z88q__lx7hzfsszf57gpkyxw0000gn/T/appium114920-24748-150rfxp.tmp”
e[36minfoe[39m: [debug] MD5 for app is 03be5545e3542a4661a6f0fe06df00ea
e[36minfoe[39m: [debug] executing: “/Users/wcs_mac/Desktop/appium/sdk/sdk/platform-tools/adb” -s emulator-5554 shell “ls /data/local/tmp/03be5545e3542a4661a6f0fe06df00ea.apk”
e[36minfoe[39m: [debug] Getting install status for com.flufflydelusions.app.enotesclassiclite
e[36minfoe[39m: [debug] Getting device API level
e[36minfoe[39m: [debug] executing: “/Users/wcs_mac/Desktop/appium/sdk/sdk/platform-tools/adb” -s emulator-5554 shell “getprop ro.build.version.sdk”
e[36minfoe[39m: [debug] Device is at API Level 19
e[36minfoe[39m: [debug] executing: “/Users/wcs_mac/Desktop/appium/sdk/sdk/platform-tools/adb” -s emulator-5554 shell “pm list packages -3 com.flufflydelusions.app.enotesclassiclite”
e[36minfoe[39m: [debug] App is installed
e[36minfoe[39m: App is already installed, resetting app
e[36minfoe[39m: [debug] Running fast reset (stop and clear)
e[36minfoe[39m: [debug] executing: “/Users/wcs_mac/Desktop/appium/sdk/sdk/platform-tools/adb” -s emulator-5554 shell “am force-stop com.flufflydelusions.app.enotesclassiclite”
e[36minfoe[39m: [debug] executing: “/Users/wcs_mac/Desktop/appium/sdk/sdk/platform-tools/adb” -s emulator-5554 shell “pm clear com.flufflydelusions.app.enotesclassiclite”
e[36minfoe[39m: [debug] Forwarding system:4724 to device:4724
e[36minfoe[39m: [debug] executing: “/Users/wcs_mac/Desktop/appium/sdk/sdk/platform-tools/adb” -s emulator-5554 forward tcp:4724 tcp:4724
e[36minfoe[39m: [debug] Pushing appium bootstrap to device…
e[36minfoe[39m: [debug] executing: “/Users/wcs_mac/Desktop/appium/sdk/sdk/platform-tools/adb” -s emulator-5554 push “/usr/local/lib/node_modules/appium/build/android_bootstrap/AppiumBootstrap.jar” /data/local/tmp/
e[36minfoe[39m: [debug] Pushing settings apk to device…
e[36minfoe[39m: [debug] executing: “/Users/wcs_mac/Desktop/appium/sdk/sdk/platform-tools/adb” -s emulator-5554 install “/usr/local/lib/node_modules/appium/build/settings_apk/settings_apk-debug.apk”
e[36minfoe[39m: [debug] Pushing unlock helper app to device…
e[36minfoe[39m: [debug] executing: “/Users/wcs_mac/Desktop/appium/sdk/sdk/platform-tools/adb” -s emulator-5554 install “/usr/local/lib/node_modules/appium/build/unlock_apk/unlock_apk-debug.apk”
e[36minfoe[39m: Starting App
e[36minfoe[39m: [debug] Attempting to kill all ‘uiautomator’ processes
e[36minfoe[39m: [debug] Getting all processes with ‘uiautomator’
e[36minfoe[39m: [debug] executing: “/Users/wcs_mac/Desktop/appium/sdk/sdk/platform-tools/adb” -s emulator-5554 shell “ps ‘uiautomator’”
e[36minfoe[39m: [debug] No matching processes found
e[36minfoe[39m: [debug] Running bootstrap
e[36minfoe[39m: [debug] spawning: /Users/wcs_mac/Desktop/appium/sdk/sdk/platform-tools/adb -s emulator-5554 shell uiautomator runtest AppiumBootstrap.jar -c io.appium.android.bootstrap.Bootstrap
e[36minfoe[39m: [debug] e[90m[UIAUTOMATOR STDOUT] WARNING: linker:e[39m
e[36minfoe[39m: [debug] e[90m[UIAUTOMATOR STDOUT] libdvm.soe[39m
e[36minfoe[39m: [debug] e[90m[UIAUTOMATOR STDOUT] has text relocations. This is wasting memory and is a security risk. Please fix.e[39m
e[36minfoe[39m: [debug] e[90m[UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: numtests=1e[39m
e[36minfoe[39m: [debug] e[90m[UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: stream=e[39m
e[36minfoe[39m: [debug] e[90m[UIAUTOMATOR STDOUT] io.appium.android.bootstrap.Bootstrap:e[39m
e[36minfoe[39m: [debug] e[90m[UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: id=UiAutomatorTestRunnere[39m
e[36minfoe[39m: [debug] e[90m[UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: test=testRunServere[39m
e[36minfoe[39m: [debug] e[90m[UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: class=io.appium.android.bootstrap.Bootstrape[39m
e[36minfoe[39m: [debug] e[90m[UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: current=1e[39m
e[36minfoe[39m: [debug] e[90m[UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS_CODE: 1e[39m
e[36minfoe[39m: [debug] [BOOTSTRAP] [debug] Socket opened on port 4724
e[36minfoe[39m: [debug] [BOOTSTRAP] [debug] Appium Socket Server Ready
e[36minfoe[39m: [debug] Waking up device if it’s not alive
e[36minfoe[39m: [debug] Pushing command to appium work queue: [“wake”,{}]
e[36minfoe[39m: [debug] [BOOTSTRAP] [debug] Loading json…
e[36minfoe[39m: [debug] [BOOTSTRAP] [debug] json loading complete.
e[36minfoe[39m: [debug] [BOOTSTRAP] [debug] Registered crash watchers.
e[36minfoe[39m: [debug] [BOOTSTRAP] [debug] Client connected
e[36minfoe[39m: [debug] [BOOTSTRAP] [debug] Got data from client: {“cmd”:“action”,“action”:“wake”,“params”:{}}
e[36minfoe[39m: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
e[36minfoe[39m: [debug] [BOOTSTRAP] [debug] Got command action: wake
e[36minfoe[39m: [debug] [BOOTSTRAP] [debug] Returning result: {“value”:true,“status”:0}
e[36minfoe[39m: [debug] executing: “/Users/wcs_mac/Desktop/appium/sdk/sdk/platform-tools/adb” -s emulator-5554 shell “dumpsys window”
e[36minfoe[39m: [debug] Writing dumpsys output to /usr/local/lib/node_modules/appium/.dumpsys.log
e[36minfoe[39m: Unlocking screen
e[36minfoe[39m: [debug] Screen is locked, trying to unlock
e[36minfoe[39m: [debug] Getting device API level
e[36minfoe[39m: [debug] executing: “/Users/wcs_mac/Desktop/appium/sdk/sdk/platform-tools/adb” -s emulator-5554 shell “getprop ro.build.version.sdk”
e[36minfoe[39m: [debug] Device is at API Level 19
e[36minfoe[39m: [debug] executing: “/Users/wcs_mac/Desktop/appium/sdk/sdk/platform-tools/adb” -s emulator-5554 shell “am start -S -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -f 0x10200000 -n io.appium.unlock/.Unlock”
e[36minfoe[39m: [debug] executing: “/Users/wcs_mac/Desktop/appium/sdk/sdk/platform-tools/adb” -s emulator-5554 shell “dumpsys window”
e[36minfoe[39m: [debug] Writing dumpsys output to /usr/local/lib/node_modules/appium/.dumpsys.log
e[36minfoe[39m: [debug] Stopping logcat capture
e[36minfoe[39m: [debug] Logcat terminated with code null, signal SIGTERM
e[36minfoe[39m: [debug] [BOOTSTRAP] [debug] Got data from client: {“cmd”:“shutdown”}
e[36minfoe[39m: [debug] [BOOTSTRAP] [debug] Got command of type SHUTDOWN
e[36minfoe[39m: [debug] [BOOTSTRAP] [debug] Returning result: {“value”:“OK, shutting down”,“status”:0}
e[36minfoe[39m: [debug] Sent shutdown command, waiting for UiAutomator to stop…
e[36minfoe[39m: [debug] [BOOTSTRAP] [debug] Closed client connection
e[36minfoe[39m: [debug] e[90m[UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: numtests=1e[39m
e[36minfoe[39m: [debug] e[90m[UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: stream=.e[39m
e[36minfoe[39m: [debug] e[90m[UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: id=UiAutomatorTestRunnere[39m
e[36minfoe[39m: [debug] e[90m[UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: test=testRunServere[39m
e[36minfoe[39m: [debug] e[90m[UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: class=io.appium.android.bootstrap.Bootstrape[39m
e[36minfoe[39m: [debug] e[90m[UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: current=1e[39m
e[36minfoe[39m: [debug] e[90m[UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS_CODE: 0e[39m
e[36minfoe[39m: [debug] e[90m[UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: stream=e[39m
e[36minfoe[39m: [debug] e[90m[UIAUTOMATOR STDOUT] Test results for WatcherResultPrinter=.e[39m
e[36minfoe[39m: [debug] e[90m[UIAUTOMATOR STDOUT] Time: 11.754e[39m
e[36minfoe[39m: [debug] e[90m[UIAUTOMATOR STDOUT] OK (1 test)e[39m
e[36minfoe[39m: [debug] e[90m[UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS_CODE: -1e[39m
e[36minfoe[39m: [debug] UiAutomator shut down normally
e[36minfoe[39m: [debug] Cleaning up android objects
e[36minfoe[39m: [debug] Cleaning up appium session
e[31merrore[39m: Failed to start an Appium session, err was: Error: Screen did not unlock
e[36minfoe[39m: [debug] Error: Screen did not unlock
at null. (/usr/local/lib/node_modules/appium/lib/devices/android/android-common.js:686:25)
at /usr/local/lib/node_modules/appium/node_modules/appium-adb/lib/adb.js:1489:9
at null. (/usr/local/lib/node_modules/appium/node_modules/appium-adb/lib/adb.js:172:9)
at ChildProcess.exithandler (child_process.js:646:7)
at ChildProcess.emit (events.js:98:17)
at maybeClose (child_process.js:756:16)
at Socket. (child_process.js:969:11)
at Socket.emit (events.js:95:17)
at Pipe.close (net.js:465:12)
e[36minfoe[39m: [debug] Responding to client with error: {“status”:33,“value”:{“message”:“A new session could not be created. (Original error: Screen did not unlock)”,“origValue”:“Screen did not unlock”},“sessionId”:null}
e[36minfoe[39m: e[37m<-- POST /wd/hub/session e[39me[31m500e[39me[90m 158676.543 ms - 164e[39m e[90me[39m