skipServerInstallation

Appium has a skipServerInstallation capability that I’m interested in using to improve startup performance

Skip uiAutomator2 server installation and use uiAutomator2 server from the device. Can be used to improve startup performance when an uiAutomator2 server in proper version is already installed on the device. Defaults to false .

But where can I obtain the UiAutomator2 server? Do I just download a pre-built APK somewhere (or build it myself?) and pre-install it on the device?

These apks are already present inside appium modules. You could see full paths to them in the server log for session startup

Thanks for the input! I see a few APK in the logs, which do I need exactly?

  • /usr/lib/node_modules/appium/node_modules/appium-uiautomator2-server/apks/appium-uiautomator2-server-debug-androidTest.apk
  • /usr/lib/node_modules/appium/node_modules/appium-uiautomator2-server/apks/appium-uiautomator2-server-v4.5.5.apk
  • /usr/lib/node_modules/appium/node_modules/io.appium.settings/apks/settings_apk-debug.apk

Obviously these, that have server in their names

I installed all the above APK and now Appium does not seem to be functioning as expected

connected to 18.196.102.89:10002
[Appium] Welcome to Appium v1.17.1
[Appium] Non-default server args:
[Appium]   allowInsecure: {
[Appium]     0: execute_driver_script
[Appium]   }
[Appium] Appium REST http interface listener started on 0.0.0.0:4723
[HTTP] --> POST /wd/hub/session
[HTTP] {"capabilities":{"alwaysMatch":{"platformName":"Android","platformVersion":"10","deviceName":"Android Emulator","noReset":true,"newCommandTimeout":86400,"automationName":"UiAutomator2","appWaitPackage":"com.ubercab.driver","appWaitActivity":"com.ubercab.carbon.core.CarbonActivity","skipServerInstallation":true,"skipDeviceInitialization":true,"noSign":true,"skipUnlock":true,"skipLogcatCapture":true},"firstMatch":[{}]},"desiredCapabilities":{"platformName":"Android","platformVersion":"10","deviceName":"Android Emulator","noReset":true,"newCommandTimeout":86400,"automationName":"UiAutomator2","appWaitPackage":"com.ubercab.driver","appWaitActivity":"com.ubercab.carbon.core.CarbonActivity","skipServerInstallation":true,"skipDeviceInitialization":true,"noSign":true,"skipUnlock":true,"skipLogcatCapture":true}}
[debug] [W3C] Calling AppiumDriver.createSession() with args: [{"platformName":"Android","platformVersion":"10","deviceName":"Android Emulator","noReset":true,"newCommandTimeout":86400,"automationName":"UiAutomator2","appWaitPackage":"com.ubercab.driver","appWaitActivity":"com.ubercab.carbon.core.CarbonActivity","skipServerInstallation":true,"skipDeviceInitialization":true,"noSign":true,"skipUnlock":true,"skipLogcatCapture":true},null,{"alwaysMatch":{"platformName":"Android","platformVersion":"10","deviceName":"Android Emulator","noReset":true,"newCommandTimeout":86400,"automationName":"UiAutomator2","appWaitPackage":"com.ubercab.driver","appWaitActivity":"com.ubercab.carbon.core.CarbonActivity","skipServerInstallation":true,"skipDeviceInitialization":true,"noSign":true,"skipUnlock":true,"skipLogcatCapture":true},"firstMatch":[{}]}]
[debug] [BaseDriver] Event 'newSessionRequested' logged at 1600777403063 (12:23:23 GMT+0000 (Coordinated Universal Time))
[BaseDriver] The following capabilities are not standard capabilities and should have an extension prefix:
[BaseDriver]   platformVersion
[BaseDriver]   deviceName
[BaseDriver]   noReset
[BaseDriver]   newCommandTimeout
[BaseDriver]   automationName
[BaseDriver]   appWaitPackage
[BaseDriver]   appWaitActivity
[BaseDriver]   skipServerInstallation
[BaseDriver]   skipDeviceInitialization
[BaseDriver]   noSign
[BaseDriver]   skipUnlock
[BaseDriver]   skipLogcatCapture
[Appium] Appium v1.17.1 creating new AndroidUiautomator2Driver (v1.44.2) session
[Appium] Explicitly enabling use of insecure features:
[Appium]     execute_driver_script
[debug] [BaseDriver] W3C capabilities and MJSONWP desired capabilities were provided
[debug] [BaseDriver] Creating session with W3C capabilities: {
[debug] [BaseDriver]   "alwaysMatch": {
[debug] [BaseDriver]     "platformName": "Android",
[debug] [BaseDriver]     "appium:platformVersion": "10",
[debug] [BaseDriver]     "appium:deviceName": "Android Emulator",
[debug] [BaseDriver]     "appium:noReset": true,
[debug] [BaseDriver]     "appium:newCommandTimeout": 86400,
[debug] [BaseDriver]     "appium:automationName": "UiAutomator2",
[debug] [BaseDriver]     "appium:appWaitPackage": "com.ubercab.driver",
[debug] [BaseDriver]     "appium:appWaitActivity": "com.ubercab.carbon.core.CarbonActivity",
[debug] [BaseDriver]     "appium:skipServerInstallation": true,
[debug] [BaseDriver]     "appium:skipDeviceInitialization": true,
[debug] [BaseDriver]     "appium:noSign": true,
[debug] [BaseDriver]     "appium:skipUnlock": true,
[debug] [BaseDriver]     "appium:skipLogcatCapture": true
[debug] [BaseDriver]   },
[debug] [BaseDriver]   "firstMatch": [
[debug] [BaseDriver]     {}
[debug] [BaseDriver]   ]
[debug] [BaseDriver] }
[BaseDriver] Session created with session id: 638dc485-7004-4422-9c14-890b6881cc63
[UiAutomator2] Neither 'app' nor 'appPackage' was set. Starting UiAutomator2 without the target application
[ADB] Found 1 'build-tools' folders under '/root' (newest first):
[ADB]     /root/build-tools/29.0.3
[ADB] Using 'adb' from '/root/platform-tools/adb'
[AndroidDriver] Retrieving device list
[debug] [ADB] Trying to find a connected android device
[debug] [ADB] Getting connected devices...
[debug] [ADB] Connected devices: [{"udid":"18.196.102.89:10002","state":"device"}]
[AndroidDriver] Looking for a device with Android '10.0.0'
[debug] [ADB] Setting device id to 18.196.102.89:10002
[ADB] Getting device platform version
[debug] [ADB] Running '/root/platform-tools/adb -P 5037 -s 18.196.102.89\:10002 shell getprop ro.build.version.release'
[debug] [ADB] Current device property 'ro.build.version.release': 10
[AndroidDriver] Using device: 18.196.102.89:10002
[ADB] Using 'adb' from '/root/platform-tools/adb'
[debug] [ADB] Setting device id to 18.196.102.89:10002
[debug] [ADB] Running '/root/platform-tools/adb -P 5037 -s 18.196.102.89\:10002 shell getprop ro.build.version.sdk'
[debug] [ADB] Current device property 'ro.build.version.sdk': 29
[ADB] Getting device platform version
[debug] [ADB] Running '/root/platform-tools/adb -P 5037 -s 18.196.102.89\:10002 shell getprop ro.build.version.release'
[debug] [ADB] Current device property 'ro.build.version.release': 10
[debug] [ADB] Device API level: 29
[UiAutomator2] Relaxing hidden api policy
[debug] [ADB] Running '/root/platform-tools/adb -P 5037 -s 18.196.102.89\:10002 shell settings put global hidden_api_policy_pre_p_apps 1'
[debug] [ADB] Running '/root/platform-tools/adb -P 5037 -s 18.196.102.89\:10002 shell settings put global hidden_api_policy_p_apps 1'
[debug] [ADB] Running '/root/platform-tools/adb -P 5037 -s 18.196.102.89\:10002 shell settings put global hidden_api_policy 1'
[AndroidDriver] No app sent in, not parsing package/activity
[AndroidDriver] 'skipDeviceInitialization' is set. Skipping device initialization.
[debug] [ADB] Running '/root/platform-tools/adb -P 5037 -s 18.196.102.89\:10002 shell appops set io.appium.settings android\:mock_location allow'
[AndroidDriver] 'skipLogcatCapture' is set. Skipping starting logcat capture.
[debug] [UiAutomator2] Forwarding UiAutomator2 Server port 6790 to 8200
[debug] [ADB] Forwarding system: 8200 to device: 6790
[debug] [ADB] Running '/root/platform-tools/adb -P 5037 -s 18.196.102.89\:10002 forward tcp\:8200 tcp\:6790'
[UiAutomator2] 'skipServerInstallation' is set. Skipping UIAutomator2 server installation.
[debug] [UiAutomator2] No app capability. Assuming it is already on the device
[debug] [UiAutomator2] Performing shallow cleanup of automation leftovers
[debug] [UiAutomator2] No obsolete sessions have been detected (Error: socket hang up)
[debug] [ADB] Running '/root/platform-tools/adb -P 5037 -s 18.196.102.89\:10002 shell am force-stop io.appium.uiautomator2.server.test'
[UiAutomator2] 'skipServerInstallation' is set. Attempting to use UIAutomator2 server from the device
[UiAutomator2] Waiting up to 30000ms for UiAutomator2 to be online...
[debug] [ADB] Creating ADB subprocess with args: ["-P",5037,"-s","18.196.102.89:10002","shell","am","instrument","-w","io.appium.uiautomator2.server.test/androidx.test.runner.AndroidJUnitRunner"]
[debug] [Instrumentation] java.lang.SecurityException: Permission Denial: starting instrumentation ComponentInfo{io.appium.uiautomator2.server.test/androidx.test.runner.AndroidJUnitRunner} from pid=2277, uid=2277 not allowed because package io.appium.uiautomator2.server.test does not have a signature matching the target io.appium.uiautomator2.server
[debug] [Instrumentation] at android.os.Parcel.createException(Parcel.java:2071)
[debug] [Instrumentation] 	at android.os.Parcel.readException(Parcel.java:2039)
[debug] [Instrumentation] 	at android.os.Parcel.readException(Parcel.java:1987)
[debug] [Instrumentation] 	at android.app.IActivityManager$Stub$Proxy.startInstrumentation(IActivityManager.java:5443)
[debug] [Instrumentation] 	at com.android.commands.am.Instrument.run(Instrument.java:512)
[debug] [Instrumentation] 	at com.android.commands.am.Am.runInstrument(Am.java:196)
[debug] [Instrumentation] 	at com.android.commands.am.Am.onRun(Am.java:80)
[debug] [Instrumentation] 	at com.android.internal.os.BaseCommand.run(BaseCommand.java:56)
[debug] [Instrumentation] 	at com.android.commands.am.Am.main(Am.java:50)
[debug] [Instrumentation] 	at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
[debug] [Instrumentation] 	at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:338)
[debug] [Instrumentation] Caused by: android.os.RemoteException: Remote stack trace:
[debug] [Instrumentation] 	at com.android.server.am.ActivityManagerService.startInstrumentation(ActivityManagerService.java:15772)
[debug] [Instrumentation] 	at android.app.IActivityManager$Stub.onTransact(IActivityManager.java:2350)
[debug] [Instrumentation] 	at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:2741)
[debug] [Instrumentation] 	at android.os.Binder.execTransactInternal(Binder.java:1021)
[debug] [Instrumentation] 	at android.os.Binder.execTransact(Binder.java:994)
[debug] [Instrumentation] The process has exited with code 1
[UiAutomator2] The instrumentation process has been unexpectedly terminated. Retrying UiAutomator2 startup (#1 of 1)
[debug] [UiAutomator2] Performing strict cleanup of automation leftovers
[debug] [UiAutomator2] No obsolete sessions have been detected (Error: socket hang up)
[debug] [ADB] Running '/root/platform-tools/adb -P 5037 -s 18.196.102.89\:10002 shell am force-stop io.appium.uiautomator2.server.test'
[debug] [ADB] Attempting to kill all uiautomator processes
[debug] [ADB] Getting IDs of all 'uiautomator' processes
[debug] [ADB] Running '/root/platform-tools/adb -P 5037 -s 18.196.102.89\:10002 shell 'pgrep --help; echo $?''
[debug] [ADB] Running '/root/platform-tools/adb -P 5037 -s 18.196.102.89\:10002 shell pgrep -f uiautomator'
[ADB] No 'uiautomator' process has been found
[UiAutomator2] Waiting up to 30000ms for UiAutomator2 to be online...
[debug] [ADB] Creating ADB subprocess with args: ["-P",5037,"-s","18.196.102.89:10002","shell","am","instrument","-w","io.appium.uiautomator2.server.test/androidx.test.runner.AndroidJUnitRunner"]
[debug] [Instrumentation] INSTRUMENTATION_STATUS: Error=Permission Denial: starting instrumentation ComponentInfo{io.appium.uiautomator2.server.test/androidx.test.runner.AndroidJUnitRunner} from pid=2495, uid=2495 not allowed because package io.appium.uiautomator2.server.test does not have a signature matching the target io.appium.uiautomator2.server
[debug] [Instrumentation] INSTRUMENTATION_STATUS: id=ActivityManagerService
[debug] [Instrumentation] java.lang.SecurityException: Permission Denial: starting instrumentation ComponentInfo{io.appium.uiautomator2.server.test/androidx.test.runner.AndroidJUnitRunner} from pid=2495, uid=2495 not allowed because package io.appium.uiautomator2.server.test does not have a signature matching the target io.appium.uiautomator2.server
[debug] [Instrumentation] 	at android.os.Parcel.createException(Parcel.java:2071)
[debug] [Instrumentation] 	at android.os.Parcel.readException(Parcel.java:2039)
[debug] [Instrumentation] 	at android.os.Parcel.readException(Parcel.java:1987)
[debug] [Instrumentation] 	at android.app.IActivityManager$Stub$Proxy.startInstrumentation(IActivityManager.java:5443)
[debug] [Instrumentation] 	at com.android.commands.am.Instrument.run(Instrument.java:512)
[debug] [Instrumentation] 	at com.android.commands.am.Am.runInstrument(Am.java:196)
[debug] [Instrumentation] 	at com.android.commands.am.Am.onRun(Am.java:80)
[debug] [Instrumentation] 	at com.android.internal.os.BaseCommand.run(BaseCommand.java:56)
[debug] [Instrumentation] 	at com.android.commands.am.Am.main(Am.java:50)
[debug] [Instrumentation] 	at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
[debug] [Instrumentation] 	at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:338)
[debug] [Instrumentation] INSTRUMENTATION_STATUS_CODE: -1
[debug] [Instrumentation] The process has exited with code 1
[debug] [UiAutomator2] Deleting UiAutomator2 session
[debug] [UiAutomator2] Deleting UiAutomator2 server session
[debug] [WD Proxy] Matched '/' to command name 'deleteSession'
[UiAutomator2] Did not get confirmation UiAutomator2 deleteSession worked; Error was: UnknownError: An unknown server-side error occurred while processing the command. Original error: Trying to proxy a session command without session id
[debug] [ADB] Removing forwarded port socket connection: 8200
[debug] [ADB] Running '/root/platform-tools/adb -P 5037 -s 18.196.102.89\:10002 forward --remove tcp\:8200'
[UiAutomator2] Restoring hidden api policy to the device default configuration
[debug] [ADB] Running '/root/platform-tools/adb -P 5037 -s 18.196.102.89\:10002 shell settings delete global hidden_api_policy_pre_p_apps'
[debug] [ADB] Running '/root/platform-tools/adb -P 5037 -s 18.196.102.89\:10002 shell settings delete global hidden_api_policy_p_apps'
[debug] [ADB] Running '/root/platform-tools/adb -P 5037 -s 18.196.102.89\:10002 shell settings delete global hidden_api_policy'
[debug] [BaseDriver] Event 'newSessionStarted' logged at 1600777408998 (12:23:28 GMT+0000 (Coordinated Universal Time))
[debug] [W3C] Encountered internal error running command: Error: The instrumentation process cannot be initialized. Make sure the application under test does not crash and investigate the logcat output.
[debug] [W3C]     at Object.errorAndThrow (/usr/lib/node_modules/appium/node_modules/appium-support/lib/logging.js:87:35)
[debug] [W3C]     at UiAutomator2Server.startSession (/usr/lib/node_modules/appium/node_modules/appium-uiautomator2-driver/lib/uiautomator2.js:231:13)
[debug] [W3C]     at AndroidUiautomator2Driver.startUiAutomator2Session (/usr/lib/node_modules/appium/node_modules/appium-uiautomator2-driver/lib/driver.js:366:5)
[debug] [W3C]     at AndroidUiautomator2Driver.createSession (/usr/lib/node_modules/appium/node_modules/appium-uiautomator2-driver/lib/driver.js:212:7)
[debug] [W3C]     at AppiumDriver.createSession (/usr/lib/node_modules/appium/lib/appium.js:358:35)
[debug] [W3C] Destroying socket connection
[HTTP] <-- POST /wd/hub/session 500 6016 ms - 759
[HTTP]

Can’t quite debug it, do you have any pointers?

Both server binaries must be signed with the same signature

Ah so the noSign capability (which I had set) only refers to the app under test?

What tooling can I use to sign these APKs then?