Uiautomator2 error - Cannot read property 'isScreenLocked' of undefined

Android version 7.0

While running with automationName = Appium - test work fine, but instead of Appium I write uiautomator2, the error is this: [MJSONWP] Encountered internal error running command: TypeError: Cannot read property ‘isScreenLocked’ of undefined

Thanks for answers. :slight_smile:

wait next version. it is fixed.

1 Like

Thanks for announcement @Aleksei.

Do you know when next version was planned to be released?

released. try. it is “0.3.0” in appium-uiautomator2-driver

[MJSONWP] Bad parameters: BadParametersError: Parameters were incorrect. We wanted {“required”:[“desiredCapabilities”],“optional”:[“requiredCapabilities”,“capabilities”,“sessionId”,“id”]} and you sent [“capabilities”]

#serenity.properties:

# \\ Serenity properties ////
serenity.timeout = 5000
serenity.step.delay = 200
serenity.store.html.source = true
serenity.reports.show.step.detail = true
serenity.report.show.manual.tests = false
serenity.report.show.releases = false
serenity.verbose.steps = true
serenity.test.root = src/test/java/tests

# \\ Webdriver properties ////
webdriver.timeouts.implicitlywait = 29000
webdriver.wait.for.timeout = 29000
webdriver.driver = appium

# \\ Appium properties ////
simplified.stack.traces = true
appium.recreateChromeDriverSessions = true
appium.session-override = true
appium.deviceReadyTimeout = 10
appium.resetKeyboard = true
appium.autoWebviewTimeout = 6000
appium.nativeWebScreenshot = true
appium.unicodeKeyboard = true
appium.clearSystemFiles = true
appium.hub = http://0.0.0.0:4723/wd/hub

#Android
appium.platformName = Android
appium.platformVersion = 7.0
appium.deviceName = emulator-5554
appium.avd = Nexus
appium.app = /Users/user1/app.apk
appium.chromedriver-executable = /Users/user1/chromedriver
appium.automationName = uiautomator2
appium.fastReset = true

  1. appium installed with:
npm install -g appium@beta --no-shrinkwrap
  1. other config -
   appium:  start appium as: [appium, --log-level, debug, --port, 4725, --bootstrap-port, 5725, --command-timeout, 90, --session-override]

   driver: Capabilities [{app=/Users/Aleksei/Downloads/test_clients/xxxxx.apk, noReset=false, clearSystemFiles=true, appWaitActivity=ee.xxxx, ee.xxxxx, disableAndroidWatchers=true, version=, deviceName=LGH8155e9892e6, fullReset=false, platform=ANDROID, automationName=UIAutomator2, browserName=, autoGrantPermissions=true, udid=LGH8155e9892e6, platformName=Android}]

The same error. :frowning:

Could not instantiate new WebDriver instance of type class io.appium.java_client.AppiumDriver (Unable to create new remote session. desired capabilities = Capabilities [{app=/Users/user1/app.apk, autoWebviewTimeout=6000, clearSystemFiles=true, noReset=false, chromedriver-executable=/Users/chromedriver, session-override=true, deviceReadyTimeout=10, deviceName=emulator-5554, platform=ANDROID, avd=Nexus, hub=http://0.0.0.0:4723/wd/hub, nativeWebScreenshot=true, platformVersion=7.0, automationName=UIAutomator2, unicodeKeyboard=true, platformName=Android, resetKeyboard=true}], required capabilities = Capabilities [{}]

by the way. while installing appium by: npm install -g appium@beta --no-shrinkwrap, the uiautomator2 driver version is not 0.3.0 but 0.2.13

yes. 0.2.13 0 it was some confusing info mentioned on git by some reason. on mine side i do not have issue.

can you check for sure version installed with:

npm list -g appium-uiautomator2-driver

[email protected] :slight_smile:
Whitout uiautomator2 tests are running, but with it not.

try add issue with your setup. no ideas. maybe ‘chromedriver’ setting in your setup cause…

Hi,
I was also facing the issue which was raised so followed the above installations but I can see different error now

Logs:

[Appium] Welcome to Appium v1.6.3
[Appium] Appium REST http interface listener started on 0.0.0.0:4723
[HTTP] --> POST /wd/hub/session {“desiredCapabilities”:{“app”:“apk-path”,“newCommandTimeout”:“600”,“platformVersion”:“7.1”,“automationName”:“uiautomator2”,“platformName”:“Android”,“deviceName”:“emulator-5554”}}
[debug] [MJSONWP] Calling AppiumDriver.createSession() with args: [{“app”:“apk-path”,“newCommandTimeout”:“600”,“platformVersion”:“7.1”,“automationName”:“uiautomator2”,“platformName”:“Android”,“deviceName”:“emulator-5554”},null,null,null,null]
[Appium] Creating new AndroidUiautomator2Driver session
[Appium] Capabilities:
[Appium] app: ‘apk-path’
[Appium] newCommandTimeout: ‘600’
[Appium] platformVersion: ‘7.1’
[Appium] automationName: ‘uiautomator2’
[Appium] platformName: ‘Android’
[Appium] deviceName: ‘emulator-5554’
[BaseDriver] Capability ‘newCommandTimeout’ changed from string (‘600’) to integer (600). This may cause unexpected behavior
[BaseDriver] Session created with session id: 25e878b1-f9cf-4fb5-9070-d88617c91374
[BaseDriver] Using local app ‘apk-path’
[debug] [UiAutomator2] Checking whether app is actually present
[UiAutomator2] UIAutomator2 Driver version:0.2.3
[debug] [AndroidDriver] Getting Java version
[AndroidDriver] Java version is: 1.8.0_102
[ADB] Checking whether adb is present
[ADB] Using adb from /Users/admin/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 ‘7.1’
[debug] [ADB] Setting device id to emulator-5554
[ADB] Getting device platform version
[debug] [ADB] Getting connected devices…
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running ‘/Users/admin/Library/Android/sdk/platform-tools/adb’ with args: ["-P",5037,"-s",“emulator-5554”,“shell”,“getprop”,“ro.build.version.release”]
[AndroidDriver] Using device: emulator-5554
[ADB] Checking whether adb is present
[ADB] Using adb from /Users/admin/Library/Android/sdk/platform-tools/adb
[debug] [ADB] Setting device id to emulator-5554
[debug] [AndroidDriver] Parsing package and activity from app manifest
[ADB] Checking whether aapt is present
[ADB] Using aapt from /Users/admin/Library/Android/sdk/build-tools/25.0.2/aapt
[ADB] Extracting package and launch activity from manifest
[debug] [ADB] badging package: package
[debug] [ADB] badging act: Activity
[debug] [AndroidDriver] Parsed package and activity are: package/Activity
[ADB] Getting device platform version
[debug] [ADB] Getting connected devices…
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running ‘/Users/admin/Library/Android/sdk/platform-tools/adb’ with args: ["-P",5037,"-s",“emulator-5554”,“shell”,“getprop”,“ro.build.version.release”]
[debug] [ADB] Attempting to kill all io.appium.uiautomator2.server processes
[debug] [ADB] Getting all processes with io.appium.uiautomator2.server
[debug] [ADB] Getting connected devices…
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running ‘/Users/admin/Library/Android/sdk/platform-tools/adb’ with args: ["-P",5037,"-s",“emulator-5554”,“shell”,“ps”]
[ADB] No io.appium.uiautomator2.server process found to kill, continuing…
[debug] [ADB] Running ‘/Users/admin/Library/Android/sdk/platform-tools/adb’ with args: ["-P",5037,"-s",“emulator-5554”,“wait-for-device”]
[debug] [ADB] Getting connected devices…
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running ‘/Users/admin/Library/Android/sdk/platform-tools/adb’ with args: ["-P",5037,"-s",“emulator-5554”,“shell”,“echo”,“ping”]
[debug] [Logcat] Starting logcat capture
[debug] [AndroidDriver] Pushing settings apk to device…
[debug] [ADB] Running ‘/Users/admin/Library/Android/sdk/platform-tools/adb’ with args: ["-P",5037,"-s",“emulator-5554”,“install”,"/usr/local/lib/node_modules/appium/node_modules/io.appium.settings/bin/settings_apk-debug.apk"]
[debug] [ADB] Running ‘/Users/admin/Library/Android/sdk/platform-tools/adb’ with args: ["-P",5037,"-s",“emulator-5554”,“install”,"/usr/local/lib/node_modules/appium/node_modules/io.appium.settings/bin/settings_apk-debug.apk"]
[debug] [ADB] Application ‘/usr/local/lib/node_modules/appium/node_modules/io.appium.settings/bin/settings_apk-debug.apk’ already installed. Continuing.
[debug] [AndroidDriver] Pushing unlock helper app to device…
[debug] [ADB] Running ‘/Users/admin/Library/Android/sdk/platform-tools/adb’ with args: ["-P",5037,"-s",“emulator-5554”,“install”,"/usr/local/lib/node_modules/appium/node_modules/appium-unlock/bin/unlock_apk-debug.apk"]
[debug] [ADB] Running ‘/Users/admin/Library/Android/sdk/platform-tools/adb’ with args: ["-P",5037,"-s",“emulator-5554”,“install”,"/usr/local/lib/node_modules/appium/node_modules/appium-unlock/bin/unlock_apk-debug.apk"]
[debug] [ADB] Application ‘/usr/local/lib/node_modules/appium/node_modules/appium-unlock/bin/unlock_apk-debug.apk’ already installed. Continuing.
[debug] [UiAutomator2] Forwarding UiAutomator2 Server port 6790 to 8200
[debug] [ADB] Forwarding system: 8200 to device: 6790
[debug] [ADB] Running ‘/Users/admin/Library/Android/sdk/platform-tools/adb’ with args: ["-P",5037,"-s",“emulator-5554”,“forward”,“tcp:8200”,“tcp:6790”]
[debug] [ADB] Getting connected devices…
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running ‘/Users/admin/Library/Android/sdk/platform-tools/adb’ with args: ["-P",5037,"-s",“emulator-5554”,“shell”,“dumpsys”,“window”]
[AndroidDriver] Screen already unlocked, doing nothing
[debug] [AndroidDriver] Extracting strings from apk apk-path null /var/folders/w3/85v473ln4n795wf2dd39mgjw0000gn/T/package
[debug] [ADB] Extracting strings for language: default
[debug] [ADB] Getting connected devices…
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running ‘/Users/admin/Library/Android/sdk/platform-tools/adb’ with args: ["-P",5037,"-s",“emulator-5554”,“shell”,“getprop”,“ro.build.version.sdk”]
[debug] [ADB] Device API level: 25
[debug] [ADB] Getting connected devices…
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running ‘/Users/admin/Library/Android/sdk/platform-tools/adb’ with args: ["-P",5037,"-s",“emulator-5554”,“shell”,“getprop”,“persist.sys.locale”]
[debug] [ADB] Current device property ‘persist.sys.locale’:
[debug] [ADB] Getting connected devices…
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running ‘/Users/admin/Library/Android/sdk/platform-tools/adb’ with args: ["-P",5037,"-s",“emulator-5554”,“shell”,“getprop”,“ro.product.locale”]
[debug] [ADB] Current device property ‘ro.product.locale’: en-US
[debug] [ADB] No strings.xml for language ‘en’, getting default strings.xml
[debug] [ADB] Reading strings from converted strings.json
[debug] [ADB] Running ‘/Users/admin/Library/Android/sdk/platform-tools/adb’ with args: ["-P",5037,"-s",“emulator-5554”,“push”,"/var/folders/w3/85v473ln4n795wf2dd39mgjw0000gn/T/package/strings.json","/data/local/tmp"]
[debug] [ADB] Checking app cert for apk-path.
[debug] [ADB] App not signed with debug cert.
[debug] [ADB] Resigning apk.
[ADB] Error: Could not sign with default ceritficate. Original error Command ‘/Library/Java/JavaVirtualMachines/jdk1.8.0_102.jdk/Contents/Home/bin/java -jar /usr/local/lib/node_modules/appium/node_modules/appium-adb/jars/sign.jar apk-path --override’ exited with code 1
at Object.wrappedLogger.errorAndThrow (lib/logger.js:60:13)
at ADB.callee$0$0$ (…/…/…/lib/tools/apk-signing.js:21: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 run (/usr/local/lib/node_modules/appium/node_modules/core-js/library/modules/es6.promise.js:108:47)
at /usr/local/lib/node_modules/appium/node_modules/core-js/library/modules/es6.promise.js:119:28
at flush (/usr/local/lib/node_modules/appium/node_modules/core-js/library/modules/$.microtask.js:19:5)
at _combinedTickCallback (internal/process/next_tick.js:67:7)
at process._tickCallback (internal/process/next_tick.js:98:9)
[Error: Could not sign with default ceritficate. Original error Command ‘/Library/Java/JavaVirtualMachines/jdk1.8.0_102.jdk/Contents/Home/bin/java -jar /usr/local/lib/node_modules/appium/node_modules/appium-adb/jars/sign.jar apk-path --override’ exited with code 1]
[debug] [UiAutomator2] Deleting UiAutomator2 session
[debug] [UiAutomator2] Deleting UiAutomator2 server session
[UiAutomator2] Did not get confirmation UiAutomator2 deleteSession worked; Error was: Error: Trying to proxy a session command without session id
[debug] [ADB] Getting connected devices…
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running ‘/Users/admin/Library/Android/sdk/platform-tools/adb’ with args: ["-P",5037,"-s",“emulator-5554”,“shell”,“am”,“force-stop”,“package”]

I was using the below configuration.
Appium: [email protected] and also tried with [email protected]
**jdk:**1.8.0_102
platformVersion: ‘7.1’
automationName: ‘uiautomator2’
platformName: ‘Android’

Could someone help me on this please?
Thanks

hi, I’m having similar issues with appium 1.6.4:

[ADB] Cannot read version codes of /usr/local/lib/node_modules/appium/node_modules/io.appium.settings/app/build/outputs/apk/settings_apk-debug.apk and/or io.appium.settings. Assuming correct app version is already installed
[ADB] Error: Could not sign with default ceritficate. Original error Command ‘/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/bin/java -jar /usr/local/lib/node_modules/appium/node_modules/appium-adb/jars/sign.jar /usr/local/lib/node_modules/appium/node_modules/appium-uiautomator2-driver/uiautomator2/appium-uiautomator2-server-v0.1.4.apk --override’ exited with code 1

Mac OSX El Capitan 10.11.6
Appium: 1.6.4
Android: 7.1.1

@New_Tester i managed to resolve this issue. I had installed appium with sudo and that caused mentioned error. Appium should be installed without sudo, otherwise there might be some problems ahead :slight_smile:

1 Like

I didn’t install the appium with sudo, and it was good for me.

1 Like