I’m facing an issue - am not able to create a new AndroidDriver session
Session creation fails with error - “Screen did not unlock”.
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("appium-version", "2.1.0");
capabilities.setCapability("platformName", DesiredCapabilities.android());
capabilities.setCapability("deviceName", "Android");
capabilities.setCapability("platformVersion", "4.4");
capabilities.setCapability("appPackage","xxx"); capabilities.setCapability("appActivity","xxx");
Appium log
info: <-- POST /wd/hub/session 500 14307.655 ms - 164
info: --> POST /wd/hub/session {“desiredCapabilities”:{“platformVersion”:“4.4”,“deviceName”:“Android”,“platformName”:“Android”,“appActivity”:“com.amazon.gallery.thor.app.activity.ThorLauncherActivity”,“appium-version”:“2.1.0”,“name”:“Java Android tutorial Thu Nov 27 04:23:52 PST 2014”,“appPackage”:“com.amazon.photos”}}
info: Client User-Agent string: Apache-HttpClient/4.3.3 (java 1.5)
info: [debug] The following desired capabilities were provided, but not recognized by appium. They will be passed on to any other services running on this server. : appium-version, name
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 7a6c96d6-3006-4ec9-a60f-f213e4e681e1
info: Starting android appium
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: [debug] Checking whether adb is present
info: [debug] Using adb from /Users/anantsri/android/sdk/platform-tools/adb
info: Retrieving device
info: [debug] Trying to find a connected android device
info: [debug] Getting connected devices…
info: [debug] executing: “/Users/anantsri/android/sdk/platform-tools/adb” devices
info: [debug] 1 device(s) connected
info: Found device B08404044223001T
info: [debug] Setting device id to B08404044223001T
info: [debug] Waiting for device to be ready and to respond to shell commands (timeout = 5)
info: [debug] executing: “/Users/anantsri/android/sdk/platform-tools/adb” -s B08404044223001T wait-for-device
info: [debug] executing: “/Users/anantsri/android/sdk/platform-tools/adb” -s B08404044223001T shell “echo ‘ready’”
info: [debug] Starting logcat capture
warn: No app capability, can’t parse package/activity
info: [debug] Getting device API level
info: [debug] executing: “/Users/anantsri/android/sdk/platform-tools/adb” -s B08404044223001T shell “getprop ro.build.version.sdk”
info: [debug] Logcat terminated with code 1, signal null
info: [debug] Device is at API Level 19
info: Device API level is: 19
info: [debug] Apk doesn’t exist locally
info: [debug] executing: “/Users/anantsri/android/sdk/platform-tools/adb” -s B08404044223001T 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: “/Users/anantsri/android/sdk/platform-tools/adb” -s B08404044223001T forward tcp:4724 tcp:4724
info: [debug] Pushing appium bootstrap to device…
info: [debug] executing: “/Users/anantsri/android/sdk/platform-tools/adb” -s B08404044223001T push “/usr/local/lib/node_modules/appium/build/android_bootstrap/AppiumBootstrap.jar” /data/local/tmp/
info: [debug] Pushing settings apk to device…
info: [debug] executing: “/Users/anantsri/android/sdk/platform-tools/adb” -s B08404044223001T install “/usr/local/lib/node_modules/appium/build/settings_apk/settings_apk-debug.apk”
info: [debug] Pushing unlock helper app to device…
info: [debug] executing: “/Users/anantsri/android/sdk/platform-tools/adb” -s B08404044223001T install “/usr/local/lib/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: “/Users/anantsri/android/sdk/platform-tools/adb” -s B08404044223001T shell “ps ‘uiautomator’”
info: [debug] No matching processes found
info: [debug] Running bootstrap
info: [debug] spawning: /Users/anantsri/android/sdk/platform-tools/adb -s B08404044223001T shell uiautomator runtest AppiumBootstrap.jar -c io.appium.android.bootstrap.Bootstrap
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] Waking up device if it’s not alive
info: [debug] Pushing command to appium work queue: [“wake”,{}]
info: [debug] [BOOTSTRAP] [debug] Registered crash watchers.
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] [BOOTSTRAP] [debug] Returning result: {“value”:true,“status”:0}
info: [debug] executing: “/Users/anantsri/android/sdk/platform-tools/adb” -s B08404044223001T shell “dumpsys window”
info: Unlocking screen
info: [debug] Screen is locked, trying to unlock
info: [debug] Getting device API level
info: [debug] executing: “/Users/anantsri/android/sdk/platform-tools/adb” -s B08404044223001T shell “getprop ro.build.version.sdk”
info: [debug] Device is at API Level 19
info: [debug] executing: “/Users/anantsri/android/sdk/platform-tools/adb” -s B08404044223001T shell “am start -S -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -f 0x10200000 -n io.appium.unlock/.Unlock”
info: [debug] executing: “/Users/anantsri/android/sdk/platform-tools/adb” -s B08404044223001T shell “dumpsys window”
info: [debug] Screen is locked, trying to unlock
info: [debug] Getting device API level
info: [debug] executing: “/Users/anantsri/android/sdk/platform-tools/adb” -s B08404044223001T shell “getprop ro.build.version.sdk”
info: [debug] Device is at API Level 19
info: [debug] executing: “/Users/anantsri/android/sdk/platform-tools/adb” -s B08404044223001T shell “am start -S -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -f 0x10200000 -n io.appium.unlock/.Unlock”
info: [debug] executing: “/Users/anantsri/android/sdk/platform-tools/adb” -s B08404044223001T shell “dumpsys window”
info: [debug] Screen is locked, trying to unlock
info: [debug] Getting device API level
info: [debug] executing: “/Users/anantsri/android/sdk/platform-tools/adb” -s B08404044223001T shell “getprop ro.build.version.sdk”
info: [debug] Device is at API Level 19
info: [debug] executing: “/Users/anantsri/android/sdk/platform-tools/adb” -s B08404044223001T shell “am start -S -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -f 0x10200000 -n io.appium.unlock/.Unlock”
info: [debug] executing: “/Users/anantsri/android/sdk/platform-tools/adb” -s B08404044223001T shell “dumpsys window”
info: [debug] Screen is locked, trying to unlock
info: [debug] Getting device API level
info: [debug] executing: “/Users/anantsri/android/sdk/platform-tools/adb” -s B08404044223001T shell “getprop ro.build.version.sdk”
info: [debug] Device is at API Level 19
info: [debug] executing: “/Users/anantsri/android/sdk/platform-tools/adb” -s B08404044223001T shell “am start -S -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -f 0x10200000 -n io.appium.unlock/.Unlock”
info: [debug] executing: “/Users/anantsri/android/sdk/platform-tools/adb” -s B08404044223001T shell “dumpsys window”
info: [debug] Screen is locked, trying to unlock
info: [debug] Getting device API level
info: [debug] executing: “/Users/anantsri/android/sdk/platform-tools/adb” -s B08404044223001T shell “getprop ro.build.version.sdk”
info: [debug] Device is at API Level 19
info: [debug] executing: “/Users/anantsri/android/sdk/platform-tools/adb” -s B08404044223001T shell “am start -S -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -f 0x10200000 -n io.appium.unlock/.Unlock”
info: [debug] executing: “/Users/anantsri/android/sdk/platform-tools/adb” -s B08404044223001T shell “dumpsys window”
info: [debug] Screen is locked, trying to unlock
info: [debug] Getting device API level
info: [debug] executing: “/Users/anantsri/android/sdk/platform-tools/adb” -s B08404044223001T shell “getprop ro.build.version.sdk”
info: [debug] Device is at API Level 19
info: [debug] executing: “/Users/anantsri/android/sdk/platform-tools/adb” -s B08404044223001T shell “am start -S -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -f 0x10200000 -n io.appium.unlock/.Unlock”
info: [debug] executing: “/Users/anantsri/android/sdk/platform-tools/adb” -s B08404044223001T shell “dumpsys window”
info: [debug] Stopping logcat capture
info: [debug] Logcat already stopped
info: [debug] [BOOTSTRAP] [debug] Got data from client: {“cmd”:“shutdown”}
info: [debug] [BOOTSTRAP] [debug] Got command of type SHUTDOWN
info: [debug] [BOOTSTRAP] [debug] Returning result: {“value”:“OK, shutting down”,“status”:0}
info: [debug] [BOOTSTRAP] [debug] Closed client connection
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: numtests=1
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: stream=.
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: 0
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: stream=
info: [debug] [UIAUTOMATOR STDOUT] Test results for WatcherResultPrinter=.
info: [debug] [UIAUTOMATOR STDOUT] Time: 12.859
info: [debug] [UIAUTOMATOR STDOUT] OK (1 test)
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS_CODE: -1
info: [debug] Sent shutdown command, waiting for UiAutomator to stop…
info: [debug] UiAutomator shut down normally
info: [debug] Cleaning up android objects
info: [debug] Cleaning up appium session
info: [debug] Error: Screen did not unlock
at null. (/usr/local/lib/node_modules/appium/lib/devices/android/android-controller.js:396:25)
at /usr/local/lib/node_modules/appium/node_modules/appium-adb/lib/adb.js:1490:4
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)
info: [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}
info: <-- POST /wd/hub/session 500 16404.038 ms - 164
I see the below log in my device logcat logs while Appium tries to unlock the device
11-27 04:24:11.067 E/AndroidRuntime(15164): java.lang.RuntimeException: Unable to start activity ComponentInfo{io.appium.unlock/io.appium.unlock.Unlock}: java.lang.SecurityException: Requires DISABLE_KEYGUARD permission
11-27 04:24:11.067 E/AndroidRuntime(15164): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2260)
11-27 04:24:11.067 E/AndroidRuntime(15164): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2325)
11-27 04:24:11.067 E/AndroidRuntime(15164): at android.app.ActivityThread.access$800(ActivityThread.java:145)
11-27 04:24:11.067 E/AndroidRuntime(15164): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1216)
11-27 04:24:11.067 E/AndroidRuntime(15164): at android.os.Handler.dispatchMessage(Handler.java:102)
11-27 04:24:11.067 E/AndroidRuntime(15164): at android.os.Looper.loop(Looper.java:145)
11-27 04:24:11.067 E/AndroidRuntime(15164): at android.app.ActivityThread.main(ActivityThread.java:5266)
11-27 04:24:11.067 E/AndroidRuntime(15164): at java.lang.reflect.Method.invokeNative(Native Method)
11-27 04:24:11.067 E/AndroidRuntime(15164): at java.lang.reflect.Method.invoke(Method.java:515)
11-27 04:24:11.067 E/AndroidRuntime(15164): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:826)
11-27 04:24:11.067 E/AndroidRuntime(15164): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:642)
11-27 04:24:11.067 E/AndroidRuntime(15164): at dalvik.system.NativeStart.main(Native Method)
11-27 04:24:11.067 E/AndroidRuntime(15164): Caused by: java.lang.SecurityException: Requires DISABLE_KEYGUARD permission
11-27 04:24:11.067 E/AndroidRuntime(15164): at android.os.Parcel.readException(Parcel.java:1467)
11-27 04:24:11.067 E/AndroidRuntime(15164): at android.os.Parcel.readException(Parcel.java:1421)
11-27 04:24:11.067 E/AndroidRuntime(15164): at android.view.IWindowManager$Stub$Proxy.disableKeyguard(IWindowManager.java:1791)
11-27 04:24:11.067 E/AndroidRuntime(15164): at android.app.KeyguardManager$KeyguardLock.disableKeyguard(KeyguardManager.java:71)
11-27 04:24:11.067 E/AndroidRuntime(15164): at io.appium.unlock.Unlock.onCreate(Unlock.java:24)
11-27 04:24:11.067 E/AndroidRuntime(15164): at android.app.Activity.performCreate(Activity.java:5277)
11-27 04:24:11.067 E/AndroidRuntime(15164): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
11-27 04:24:11.067 E/AndroidRuntime(15164): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2213)
11-27 04:24:11.067 E/AndroidRuntime(15164): … 11 more
11-27 04:24:11.067 I/AndroidRuntime(15164): To Report FATAL to activityManagerService
Has anyone faced a similar issue with Kindle Tablets. Any know solution?