question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Appium can not start automator2 server on the real device

See original GitHub issue

The problem

The appium.uiautomator2.server can not start on device.

Environment

Appium version (or git revision) that exhibits the issue: Appium 1.6.0 Desktop OS/version used to run Appium: MACOS 10.11.6 El Capitan Node version (unless using Appium.app|exe): v6.9.0 Npm Version : 3.10.8 Mobile platform/version under test: Android 6.0 Real device or emulator/simulator: Nexus 6 java version “1.8.0_45”

Details

It seems appium can not install and run appium-uiautomator2-server to the real device and run it. I tried to work with project directly, I mean build app, install to device and run server using command: adb shell am instrument -w io.appium.uiautomator2.server.test/android.support.test.runner.AndroidJUnitRunner But run into the some problems:

  1. gredlew file in appium-uiautomator2-server created for Windows and needs to be modified to run it for Mac (change Windows (CRLF) to Unix (LF))
  2. after install app to the device impossible to start server using command: “adb shell am instrument -w io.appium.uiautomator2.server.test/android.support.test.runner.AndroidJUnitRunner” responce: INSTRUMENTATION_STATUS: id=ActivityManagerService INSTRUMENTATION_STATUS: Error=Unable to find instrumentation info for: ComponentInfo{io.appium.uiautomator2.server.test/android.support.test.runner.AndroidJUnitRunner} INSTRUMENTATION_STATUS_CODE: -1 android.util.AndroidException: INSTRUMENTATION_FAILED: io.appium.uiautomator2.server.test/android.support.test.runner.AndroidJUnitRunner at com.android.commands.am.Am.runInstrument(Am.java:1093) at com.android.commands.am.Am.onRun(Am.java:371) at com.android.internal.os.BaseCommand.run(BaseCommand.java:47) at com.android.commands.am.Am.main(Am.java:100) at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method) at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:251)

Link to Appium logs

2016-10-20 18:57:50:146 - [Appium] Welcome to Appium v1.6.0 2016-10-20 18:57:50:150 - [Appium] Non-default server args: 2016-10-20 18:57:50:152 - [Appium] port: 39730 2016-10-20 18:57:50:153 - [Appium] sessionOverride: true 2016-10-20 18:57:50:153 - [Appium] log: ‘/Users/adminadmin/IdeaProjects/conax_testframework/./artifacts/appium.log’ 2016-10-20 18:57:50:154 - [Appium] loglevel: ‘info:debug’ 2016-10-20 18:57:50:155 - [Appium] logTimestamp: true 2016-10-20 18:57:50:155 - [Appium] localTimezone: true 2016-10-20 18:57:50:203 - [Appium] Appium REST http interface listener started on 0.0.0.0:39730 2016-10-20 18:57:50:487 - [HTTP] --> GET /wd/hub/status {} 2016-10-20 18:57:50:490 - [MJSONWP] Calling AppiumDriver.getStatus() with args: [] 2016-10-20 18:57:50:501 - [MJSONWP] Responding to client with driver.getStatus() result: {“build”:{“version”:“1.6.0”,“revision”:null}} 2016-10-20 18:57:50:507 - [HTTP] <-- GET /wd/hub/status 200 17 ms - 83 2016-10-20 18:57:50:733 - [HTTP] --> POST /wd/hub/session {“desiredCapabilities”:{“appPackage”:“com.conax.golive.development”,“appActivity”:“com.conax.golive.LoginActivity”,“platformVersion”:“6.0”,“automationName”:“uiautomator2”,“platformName”:“Android”,“deviceName”:“Nexus 6”}} 2016-10-20 18:57:50:734 - [MJSONWP] Calling AppiumDriver.createSession() with args: [{“appPackage”:“com.conax.golive.development”,“appActivity”:“com.conax.golive.LoginActivity”,“platformVersion”:“6.0”,“automationName”:“uiautomator2”,“platformName”:“Android”,“deviceName”:“Nexus 6”},null,null,null] 2016-10-20 18:57:50:737 - [Appium] Creating new AndroidUiautomator2Driver session 2016-10-20 18:57:50:738 - [Appium] Capabilities: 2016-10-20 18:57:50:742 - [Appium] appPackage: ‘com.conax.golive.development’ 2016-10-20 18:57:50:743 - [Appium] appActivity: ‘com.conax.golive.LoginActivity’ 2016-10-20 18:57:50:743 - [Appium] platformVersion: ‘6.0’ 2016-10-20 18:57:50:744 - [Appium] automationName: ‘uiautomator2’ 2016-10-20 18:57:50:744 - [Appium] platformName: ‘Android’ 2016-10-20 18:57:50:745 - [Appium] deviceName: ‘Nexus 6’ 2016-10-20 18:57:50:754 - [BaseDriver] Session created with session id: 65cd84fd-2dd3-41d5-aa12-ea1df4cb684b 2016-10-20 18:57:50:852 - [AndroidDriver] Java version is: 1.8.0_45 2016-10-20 18:57:50:856 - [ADB] Checking whether adb is present 2016-10-20 18:57:50:862 - [ADB] Using adb from /Applications/android-sdk-macosx/platform-tools/adb 2016-10-20 18:57:50:863 - [AndroidDriver] Retrieving device list 2016-10-20 18:57:50:875 - [AndroidDriver] Looking for a device with Android ‘6.0’ 2016-10-20 18:57:50:876 - [ADB] Getting device platform version 2016-10-20 18:57:50:990 - [AndroidDriver] Using device: ZX1G42BRJ5 2016-10-20 18:57:50:992 - [ADB] Checking whether adb is present 2016-10-20 18:57:50:997 - [ADB] Using adb from /Applications/android-sdk-macosx/platform-tools/adb 2016-10-20 18:57:50:999 - [AndroidDriver] No app sent in, not parsing package/activity 2016-10-20 18:57:50:999 - [ADB] Getting device platform version 2016-10-20 18:57:51:275 - [ADB] No io.appium.uiautomator2.server process found to kill, continuing… 2016-10-20 18:57:54:939 - [AndroidDriver] Screen already unlocked, doing nothing 2016-10-20 18:57:57:364 - [ADB] No io.appium.uiautomator2.server process found to kill, continuing… 2016-10-20 18:57:57:364 - [UiAutomator2] Starting uiautomator2 server v0.0.3 with cmd: am,instrument,-w,io.appium.uiautomator2.server.test/android.support.test.runner.AndroidJUnitRunner 2016-10-20 18:57:57:369 - [UiAutomator2] Waiting for UiAutomator2 to be online… 2016-10-20 18:57:57:372 - [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8200/wd/hub/status] with no body 2016-10-20 18:57:57:402 - [UiAutomator2] running command… adb shell am instrument -w io.appium.uiautomator2.server.test/android.support.test.runner.AndroidJUnitRunner… 2016-10-20 18:57:58:411 - [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8200/wd/hub/status] with no body 2016-10-20 18:57:59:425 - [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8200/wd/hub/status] with no body 2016-10-20 18:58:00:437 - [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8200/wd/hub/status] with no body 2016-10-20 18:58:01:444 - [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8200/wd/hub/status] with no body 2016-10-20 18:58:02:467 - [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8200/wd/hub/status] with no body 2016-10-20 18:58:03:478 - [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8200/wd/hub/status] with no body 2016-10-20 18:58:04:494 - [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8200/wd/hub/status] with no body 2016-10-20 18:58:05:506 - [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8200/wd/hub/status] with no body 2016-10-20 18:58:06:518 - [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8200/wd/hub/status] with no body 2016-10-20 18:58:07:531 - [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8200/wd/hub/status] with no body 2016-10-20 18:58:08:542 - [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8200/wd/hub/status] with no body 2016-10-20 18:58:09:555 - [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8200/wd/hub/status] with no body 2016-10-20 18:58:10:570 - [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8200/wd/hub/status] with no body 2016-10-20 18:58:11:584 - [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8200/wd/hub/status] with no body 2016-10-20 18:58:12:600 - [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8200/wd/hub/status] with no body 2016-10-20 18:58:13:612 - [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8200/wd/hub/status] with no body 2016-10-20 18:58:14:620 - [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8200/wd/hub/status] with no body 2016-10-20 18:58:15:632 - [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8200/wd/hub/status] with no body 2016-10-20 18:58:16:643 - [JSONWP Proxy] Proxying [GET /status] to [GET http://localhost:8200/wd/hub/status] with no body 2016-10-20 18:58:17:660 - [UiAutomator2] Did not get confirmation UiAutomator2 deleteSession worked; Error was: Error: Trying to proxy a session command without session id 2016-10-20 18:58:18:676 - [MJSONWP] Encountered internal error running command: ProxyRequestError: Could not proxy command to remote server. Original error: Error: socket hang up at JWProxy.proxy$ (lib/jsonwp-proxy/proxy.js:126:13) at tryCatch (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40) at GeneratorFunctionPrototype.invoke as _invoke at GeneratorFunctionPrototype.prototype.(anonymous function) as throw at GeneratorFunctionPrototype.invoke (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37) 2016-10-20 18:58:18:681 - [HTTP] <-- POST /wd/hub/session 500 27945 ms - 216

Code To Reproduce Issue [ Good To Have ]

Driver capabilities: Device device = device() DesiredCapabilities capabilities = new DesiredCapabilities()

    capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, device.name)
    capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, device.platform)
    capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, device.platformVersion)
    capabilities.setCapability(MobileCapabilityType.AUTOMATION_NAME, 'uiautomator2')
    capabilities.setCapability(AndroidMobileCapabilityType.APP_PACKAGE, device.packageName)
    capabilities.setCapability(AndroidMobileCapabilityType.APP_ACTIVITY, '*****')

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:23 (11 by maintainers)

github_iconTop GitHub Comments

31reactions
sravanmedarapucommented, Oct 24, 2016

Yeah, it should automatically install the apks.

Can you uninstall both the apks manually and try with appium-uiautomator2-driver 0.0.6 check whether it is working or not.

uninstalling commands:

adb uninstall io.appium.uiautomator2.server
adb uninstall io.appium.uiautomator2.server.test
5reactions
prat3ikcommented, Jan 8, 2019

In order to resolve this please follow below steps:

  1. Make sure appium server is not executing.

  2. Connect your android device with USB, also verify that device is connected properly by using command: adb devices

  3. Execute below commands: adb uninstall io.appium.uiautomator2.server adb uninstall io.appium.uiautomator2.server.test

  4. Start appium server

  5. Start executing appium test cases

Read more comments on GitHub >

github_iconTop Results From Across the Web

Issue with installing Appium UIAutomator2 on virtual device
When I run appium-doctor, I don't get any errors what so ever. Everything seems to be going fine until I hit these steps:...
Read more >
UIAutomator2 (Android) - Appium
Real Device Setup · Ensure that Developer mode is turned on for the device. · Ensure that the device is connected via USB...
Read more >
Troubleshooting - Appium
Make sure Instruments.app is not open; If you're running the simulator, make sure your actual device is not plugged in; Make sure the...
Read more >
How to fix "UiAutomator2 Server cannot start because the ...
What did I try: I kill the node process before running appium to be sure there aren't previous sessions open. I check with...
Read more >
Top Appium Commands every Developer must know
Appium is a test automation tool used for testing Mobile Applications. It's open source and supports various platforms such as iOS, Android, and ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found