Not able to run tests in android emulator. ([uiautomator2] unable to force stop app)

Hello

I have created an emulator and launched it with AVD manager step in bitrise. When i try to run the appium scripts, i get an error [UIAutomator2] unable to force stop app.
then there is a time out error and the test doesnt run correctly.

error log :
Platform Name: Android
Platform Version: 7.1.1
Friendly Device Name: Pixel
STARTING APPIUM SERVER >>>>>>>>>>
APPIUM Server started
[Appium] Welcome to Appium v1.8.0
[Appium] Non-default server args:
[Appium] platformName: Android
[Appium] platformVersion: 7.1.1
[Appium] deviceName: Pixel
[Appium] app: /Users/vagrant/git/LinktGOGroovy/APP-BRAND_1.5.2.564-QA_5002.apk
[Appium] noReset: true
[Appium] appWaitActivity: com.transurban.citylink.presentation.start.ConfigActivity
[Appium] Deprecated server args:
[Appium] --platform-name => --default-capabilities ‘{“platformName”:“Android”}’
[Appium] --platform-version => --default-capabilities ‘{“platformVersion”:“7.1.1”}’
[Appium] --device-name => --default-capabilities ‘{“deviceName”:“Pixel”}’
[Appium] --app => --default-capabilities ‘{“app”:"/Users/vagrant/git/LinktGOGroovy/APP-BRAND_1.5.2.564-QA_5002.apk"}’
[Appium] --no-reset => --default-capabilities ‘{“noReset”:true}’
[Appium] --app-wait-activity => --default-capabilities ‘{“appWaitActivity”:“com.transurban.citylink.presentation.start.ConfigActivity”}’
[Appium] Default capabilities, which will be added to each request unless overridden by desired capabilities:
[Appium] platformName: Android
[Appium] platformVersion: 7.1.1
[Appium] deviceName: Pixel
[Appium] app: /Users/vagrant/git/LinktGOGroovy/APP-BRAND_1.5.2.564-QA_5002.apk
[Appium] noReset: true
[Appium] appWaitActivity: com.transurban.citylink.presentation.start.ConfigActivity
[Appium] Appium REST http interface listener started on 0.0.0.0:4723
@Logout
Feature: Logout
As a LINKT user
If i log out of the application
I want to have options to log back in quickly or log out completely
@LOUT002 @Ios @Android
Scenario Outline: As a LINKT user, I want to log out of Linkt completely # features/Logout.feature:9
Given The app is loaded for test “”
And I login as User “” and password “”
And I click the Log in as a different user button
And I am at the safety acknowledgement screen
Examples:
[HTTP] --> POST /wd/hub/session
[HTTP] {“desiredCapabilities”:{“app”:"/Users/vagrant/git/LinktGOGroovy/APP-BRAND_1.5.2.564-QA_5002.apk",“appWaitActivity”:“com.transurban.citylink.presentation.start.ConfigActivity”,“automationName”:“UiAutomator2”,“deviceName”:“Pixel”,“isHeadless”:“true”,“platformName”:“Android”,“platformVersion”:“7.1.1”,“systemPort”:“8250”},“capabilities”:{“desiredCapabilities”:{“app”:"/Users/vagrant/git/LinktGOGroovy/APP-BRAND_1.5.2.564-QA_5002.apk",“appWaitActivity”:“com.transurban.citylink.presentation.start.ConfigActivity”,“automationName”:“UiAutomator2”,“deviceName”:“Pixel”,“isHeadless”:“true”,“platformName”:“Android”,“platformVersion”:“7.1.1”,“systemPort”:“8250”},“firstMatch”:[{“platformName”:“android”}]}}
[debug] [MJSONWP] Calling AppiumDriver.createSession() with args: [{“app”:"/Users/vagrant/git/LinktGOGroovy/APP-BRAND_1.5.2.564-QA_5002.apk",“appWaitActivity”:“com.transurban.citylink.presentation.start.ConfigActivity”,“automationName”:“UiAutomator2”,“deviceName”:“Pixel”,“isHeadless”:“true”,“platformName”:“Android”,“platformVersion”:“7.1.1”,“systemPort”:“8250”},null,{“desiredCapabilities”:{“app”:"/Users/vagrant/git/LinktGOGroovy/APP-BRAND_1.5.2.564-QA_5002.apk",“appWaitActivity”:“com.transurban.citylink.presentation.start.ConfigActivity”,“automationName”:“UiAutomator2”,“deviceName”:“Pixel”,“isHeadless”:“true”,“platformName”:“Android”,“platformVersion”:“7.1.1”,“systemPort”:“8250”},“firstMatch”:[{“platformName”:“android”}]}]
[debug] [BaseDriver] Event ‘newSessionRequested’ logged at 1525920995418 (19:56:35 GMT-0700 (PDT))
[BaseDriver] The capabilities [“platformVersion”,“deviceName”,“app”,“noReset”,“appWaitActivity”] are not standard capabilities and should have an extension prefix
[Appium] Could not parse W3C capabilities: The arguments passed to the command are either invalid or malformed. Falling back to JSONWP protocol.
[Appium] The following capabilities were provided in the JSONWP desired capabilities that are missing in W3C capabilities: [“platformName”,“platformVersion”,“deviceName”,“app”,“noReset”,“appWaitActivity”,“automationName”,“isHeadless”,“systemPort”]. Falling back to JSONWP protocol.
[Appium] Creating new AndroidUiautomator2Driver (v1.9.0) session
[Appium] Capabilities:
[Appium] platformName: Android
[Appium] platformVersion: 7.1.1
[Appium] deviceName: Pixel
[Appium] app: /Users/vagrant/git/LinktGOGroovy/APP-BRAND_1.5.2.564-QA_5002.apk
[Appium] noReset: true
[Appium] appWaitActivity: com.transurban.citylink.presentation.start.ConfigActivity
[Appium] automationName: UiAutomator2
[Appium] isHeadless: true
[Appium] systemPort: 8250
[debug] [BaseDriver] Creating session with MJSONWP desired capabilities: {“platformName”:“Android”,"…
[BaseDriver] Capability ‘isHeadless’ changed from string to boolean. This may cause unexpected behavior
[BaseDriver] Capability ‘systemPort’ changed from string (‘8250’) to integer (8250). This may cause unexpected behavior
[BaseDriver] Session created with session id: f368357e-b94a-43d7-9e00-7b56bd6ea6c9
[BaseDriver] Using local app ‘/Users/vagrant/git/LinktGOGroovy/APP-BRAND_1.5.2.564-QA_5002.apk’
[debug] [UiAutomator2] Checking whether app is actually present
[debug] [AndroidDriver] Getting Java version
[AndroidDriver] Java version is: 1.8.0_172
[ADB] Checking whether adb is present
[ADB] Found 17 ‘build-tools’ folders under ‘/Users/vagrant/Library/Developer/Xamarin/android-sdk-macosx’ (newest first):
[ADB] /Users/vagrant/Library/Developer/Xamarin/android-sdk-macosx/build-tools/26.0.3
[ADB] /Users/vagrant/Library/Developer/Xamarin/android-sdk-macosx/build-tools/26.0.2
[ADB] /Users/vagrant/Library/Developer/Xamarin/android-sdk-macosx/build-tools/25.0.2
[ADB] /Users/vagrant/Library/Developer/Xamarin/android-sdk-macosx/build-tools/25.0.1
[ADB] /Users/vagrant/Library/Developer/Xamarin/android-sdk-macosx/build-tools/25.0.0
[ADB] /Users/vagrant/Library/Developer/Xamarin/android-sdk-macosx/build-tools/24.0.3
[ADB] /Users/vagrant/Library/Developer/Xamarin/android-sdk-macosx/build-tools/24.0.2
[ADB] /Users/vagrant/Library/Developer/Xamarin/android-sdk-macosx/build-tools/24.0.1
[ADB] /Users/vagrant/Library/Developer/Xamarin/android-sdk-macosx/build-tools/24.0.0
[ADB] /Users/vagrant/Library/Developer/Xamarin/android-sdk-macosx/build-tools/23.0.3
[ADB] /Users/vagrant/Library/Developer/Xamarin/android-sdk-macosx/build-tools/23.0.2
[ADB] /Users/vagrant/Library/Developer/Xamarin/android-sdk-macosx/build-tools/23.0.1
[ADB] /Users/vagrant/Library/Developer/Xamarin/android-sdk-macosx/build-tools/22.0.1
[ADB] /Users/vagrant/Library/Developer/Xamarin/android-sdk-macosx/build-tools/21.1.2
[ADB] /Users/vagrant/Library/Developer/Xamarin/android-sdk-macosx/build-tools/20.0.0
[ADB] /Users/vagrant/Library/Developer/Xamarin/android-sdk-macosx/build-tools/19.1.0
[ADB] /Users/vagrant/Library/Developer/Xamarin/android-sdk-macosx/build-tools/17.0.0
[ADB] Using adb from /Users/vagrant/Library/Developer/Xamarin/android-sdk-macosx/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.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/vagrant/Library/Developer/Xamarin/android-sdk-macosx/platform-tools/adb -P 5037 -s emulator-5554 shell getprop ro.build.version.release’
[debug] [ADB] Current device property ‘ro.build.version.release’: 7.1.1
[AndroidDriver] Using device: emulator-5554
[ADB] Checking whether adb is present
[ADB] Using adb from /Users/vagrant/Library/Developer/Xamarin/android-sdk-macosx/platform-tools/adb
[debug] [ADB] Setting device id to emulator-5554
[debug] [ADB] Getting connected devices…
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running ‘/Users/vagrant/Library/Developer/Xamarin/android-sdk-macosx/platform-tools/adb -P 5037 -s emulator-5554 shell getprop ro.build.version.sdk’
[debug] [ADB] Current device property ‘ro.build.version.sdk’: 25
[debug] [ADB] Device API level: 25
[debug] [AndroidDriver] Parsing package and activity from app manifest
[ADB] Using apkanalyzer from /Users/vagrant/Library/Developer/Xamarin/android-sdk-macosx/tools/bin/apkanalyzer
[debug] [ADB] Starting ‘/Users/vagrant/Library/Developer/Xamarin/android-sdk-macosx/tools/bin/apkanalyzer’ with args ["-h",“manifest”,“print”,"/Users/vagrant/git/LinktGOGroovy/APP-BRAND_1.5.2.564-QA_5002.apk"]
[ADB] Package name: ‘com.transurban.linkt.sit’
[ADB] Main activity name: ‘com.transurban.citylink.presentation.start.ConfigActivity’
[debug] [AndroidDriver] Parsed package and activity are: com.transurban.linkt.sit/com.transurban.citylink.presentation.start.ConfigActivity
[ADB] Getting device platform version
[debug] [ADB] Getting connected devices…
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running ‘/Users/vagrant/Library/Developer/Xamarin/android-sdk-macosx/platform-tools/adb -P 5037 -s emulator-5554 shell getprop ro.build.version.release’
[debug] [ADB] Current device property ‘ro.build.version.release’: 7.1.1
[debug] [ADB] Getting connected devices…
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running ‘/Users/vagrant/Library/Developer/Xamarin/android-sdk-macosx/platform-tools/adb -P 5037 -s emulator-5554 shell wm size’
[debug] [ADB] Running ‘/Users/vagrant/Library/Developer/Xamarin/android-sdk-macosx/platform-tools/adb -P 5037 -s emulator-5554 shell wm size’
[debug] [UiAutomator2] Deleting UiAutomator2 session
[debug] [ADB] Getting connected devices…
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running ‘/Users/vagrant/Library/Developer/Xamarin/android-sdk-macosx/platform-tools/adb -P 5037 -s emulator-5554 shell am force-stop com.transurban.linkt.sit’
[debug] [ADB] Running ‘/Users/vagrant/Library/Developer/Xamarin/android-sdk-macosx/platform-tools/adb -P 5037 -s emulator-5554 shell am force-stop com.transurban.linkt.sit’
[UiAutomator2] Unable to force stop app: Error executing adbExec. Original error: ‘Command ‘/Users/vagrant/Library/Developer/Xamarin/android-sdk-macosx/platform-tools/adb -P 5037 -s emulator-5554 shell am force-stop com.transurban.linkt.sit’ timed out after 20000ms’; Stderr: ‘’; Code: ‘null’
[debug] [ADB] Removing forwarded port socket connection: 8250
[debug] [ADB] Running ‘/Users/vagrant/Library/Developer/Xamarin/android-sdk-macosx/platform-tools/adb -P 5037 -s emulator-5554 forward --remove tcp:8250’
[debug] [ADB] Running ‘/Users/vagrant/Library/Developer/Xamarin/android-sdk-macosx/platform-tools/adb -P 5037 -s emulator-5554 forward --remove tcp:8250’
[UiAutomator2] Unable to remove port forward ‘Error executing adbExec. Original error: ‘Command ‘/Users/vagrant/Library/Developer/Xamarin/android-sdk-macosx/platform-tools/adb -P 5037 -s emulator-5554 forward --remove tcp:8250’ exited with code 1’; Stderr: ‘error: listener ‘tcp:8250’ not found’; Code: ‘1’’
[debug] [BaseDriver] Event ‘newSessionStarted’ logged at 1525921084731 (19:58:04 GMT-0700 (PDT))
[W3C] Encountered internal error running command: Error: Error executing adbExec. Original error: ‘Command ‘/Users/vagrant/Library/Developer/Xamarin/android-sdk-macosx/platform-tools/adb -P 5037 -s emulator-5554 shell wm size’ exited with code 1’; Stderr: ‘Error type 2
[W3C] android.util.AndroidException: Can’t connect to window manager; is the system running?
[W3C] at com.android.commands.wm.Wm.onRun(Wm.java:82)
[W3C] at com.android.internal.os.BaseCommand.run(BaseCommand.java:51)
[W3C] at com.android.commands.wm.Wm.main(Wm.java:47)
[W3C] at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
[W3C] at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:262)’; Code: ‘1’
[W3C] at ADB.execFunc$ (/usr/local/lib/node_modules/appium/node_modules/appium-adb/lib/tools/system-calls.js:317:13)
[W3C] at tryCatch (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40)
[W3C] at GeneratorFunctionPrototype.invoke [as _invoke] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:315:22)
[W3C] at GeneratorFunctionPrototype.prototype.(anonymous function) [as throw] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)
[W3C] at GeneratorFunctionPrototype.invoke (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37)
[W3C] at
[HTTP] <-- POST /wd/hub/session 500 89386 ms - 2330
[HTTP]
Failure in before hook:env.groovy:22
Message: org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. Original error: Error executing adbExec. Original error: ‘Command ‘/Users/vagrant/Library/Developer/Xamarin/android-sdk-macosx/platform-tools/adb -P 5037 -s emulator-5554 shell wm size’ exited with code 1’; Stderr: ‘Error type 2
android.util.AndroidException: Can’t connect to window manager; is the system running?
at com.android.commands.wm.Wm.onRun(Wm.java:82)
at com.android.internal.os.BaseCommand.run(BaseCommand.java:51)
at com.android.commands.wm.Wm.main(Wm.java:47)
at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:262)’; Code: ‘1’
Build info: version: ‘3.11.0’, revision: ‘e59cfb3’, time: ‘2018-03-11T20:26:55.152Z’
System info: host: ‘controlosxprodc2bhostprebootedxamarin101.local’, ip: ‘fe80:0:0:0:3b:8e85:81c8:cfe%en0’, os.name: ‘Mac OS X’, os.arch: ‘x86_64’, os.version: ‘10.13.4’, java.version: ‘1.8.0_172’
Driver info: driver.version: AndroidDriver
remote stacktrace: UnknownError: An unknown server-side error occurred while processing the command. Original error: Error executing adbExec. Original error: ‘Command ‘/Users/vagrant/Library/Developer/Xamarin/android-sdk-macosx/platform-tools/adb -P 5037 -s emulator-5554 shell wm size’ exited with code 1’; Stderr: ‘Error type 2
android.util.AndroidException: Can’t connect to window manager; is the system running?
at com.android.commands.wm.Wm.onRun(Wm.java:82)
at com.android.internal.os.BaseCommand.run(BaseCommand.java:51)
at com.android.commands.wm.Wm.main(Wm.java:47)
at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:262)’; Code: ‘1’
at getResponseForW3CError (/usr/local/lib/node_modules/appium/node_modules/appium-base-driver/lib/protocol/errors.js:800:13)
at asyncHandler$ (/usr/local/lib/node_modules/appium/node_modules/appium-base-driver/lib/protocol/protocol.js:352:37)
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

Hi @HRavichandran,

Can you please fill out a #issues:build-issues report (at http://discuss.bitrise.io/c/issues/build-issues )? It’d help a lot to be able to help you efficiently! :slight_smile:

This topic was automatically closed after 14 days. New replies are no longer allowed.