How to increase timeout for Appium Settings installation during init process?

I am experiencing a timeout during Appium Settings installation in CI using the Android v26 emulator and TestNG for capabilities and etc. I have tried putting a value androidInstallTimeout into desired capabilities but it never worked.

I attach the logs from CI there:

5554 shell pm get-install-location' exited with code 1'; Stderr: 'Error: Could not access the Package Manager.  Is the system running?'; Code: '1'
 [debug] [ADB] Running '/usr/local/share/android-sdk/platform-tools/adb -P 5037 -s emulator-5554 shell getprop init.svc.bootanim'
 [debug] [ADB] Running '/usr/local/share/android-sdk/platform-tools/adb -P 5037 -s emulator-5554 shell pm get-install-location'
 [debug] [ADB] Waiting for emulator startup. Intermediate error: Error executing adbExec. Original error: 'Command '/usr/local/share/android-sdk/platform-tools/adb -P 5037 -s emulator-5554 shell pm get-install-location' exited with code 1'; Stderr: 'Error: Could not access the Package Manager.  Is the system running?'; Code: '1'
 [debug] [ADB] Running '/usr/local/share/android-sdk/platform-tools/adb -P 5037 -s emulator-5554 shell getprop init.svc.bootanim'
 [debug] [ADB] Running '/usr/local/share/android-sdk/platform-tools/adb -P 5037 -s emulator-5554 shell pm get-install-location'
 [debug] [ADB] Waiting for emulator startup. Intermediate error: Error executing adbExec. Original error: 'Command '/usr/local/share/android-sdk/platform-tools/adb -P 5037 -s emulator-5554 shell pm get-install-location' exited with code 1'; Stderr: 'Error: Could not access the Package Manager.  Is the system running?'; Code: '1'
 [debug] [ADB] Running '/usr/local/share/android-sdk/platform-tools/adb -P 5037 -s emulator-5554 shell getprop init.svc.bootanim'
 [debug] [ADB] Running '/usr/local/share/android-sdk/platform-tools/adb -P 5037 -s emulator-5554 shell pm get-install-location'
 [AndroidDriver] Using device: emulator-5554
 [ADB] Using 'adb' from '/usr/local/share/android-sdk/platform-tools/adb'
 [debug] [ADB] Setting device id to emulator-5554
 [debug] [ADB] Running '/usr/local/share/android-sdk/platform-tools/adb -P 5037 -s emulator-5554 shell getprop ro.build.version.sdk'
 [debug] [ADB] Current device property 'ro.build.version.sdk': 26
 [debug] [ADB] Device API level: 26
 [AndroidDriver] No app sent in, not parsing package/activity
 [debug] [ADB] Running '/usr/local/share/android-sdk/platform-tools/adb -P 5037 -s emulator-5554 wait-for-device'
 [debug] [ADB] Running '/usr/local/share/android-sdk/platform-tools/adb -P 5037 -s emulator-5554 shell echo ping'
 [debug] [AndroidDriver] Pushing settings apk to device...
 [debug] [ADB] Getting install status for io.appium.settings
 [debug] [ADB] Running '/usr/local/share/android-sdk/platform-tools/adb -P 5037 -s emulator-5554 shell dumpsys package io.appium.settings'
 [debug] [ADB] 'io.appium.settings' is not installed
 [debug] [ADB] App '/usr/local/lib/node_modules/appium/node_modules/io.appium.settings/apks/settings_apk-debug.apk' is not installed
 [debug] [ADB] Installing '/usr/local/lib/node_modules/appium/node_modules/io.appium.settings/apks/settings_apk-debug.apk'
 [debug] [ADB] Running '/usr/local/share/android-sdk/platform-tools/adb -P 5037 -s emulator-5554 help'
 [debug] [ADB] Running '/usr/local/share/android-sdk/platform-tools/adb -P 5037 -s emulator-5554 features'
 [ADB] The application at '/usr/local/lib/node_modules/appium/node_modules/io.appium.settings/apks/settings_apk-debug.apk' will not be cached, because the device under test has confirmed the support of streamed installs
 [debug] [ADB] Running '/usr/local/share/android-sdk/platform-tools/adb -P 5037 -s emulator-5554 install -g /usr/local/lib/node_modules/appium/node_modules/io.appium.settings/apks/settings_apk-debug.apk'
 [debug] [ADB] Getting install status for io.appium.settings
 [debug] [ADB] Running '/usr/local/share/android-sdk/platform-tools/adb -P 5037 -s emulator-5554 shell dumpsys package io.appium.settings'
 [debug] [ADB] 'io.appium.settings' is not installed
 [debug] [ADB] App '/usr/local/lib/node_modules/appium/node_modules/io.appium.settings/apks/settings_apk-debug.apk' is not installed
 [debug] [ADB] Installing '/usr/local/lib/node_modules/appium/node_modules/io.appium.settings/apks/settings_apk-debug.apk'
 [ADB] The application at '/usr/local/lib/node_modules/appium/node_modules/io.appium.settings/apks/settings_apk-debug.apk' will not be cached, because the device under test has confirmed the support of streamed installs
 [debug] [ADB] Running '/usr/local/share/android-sdk/platform-tools/adb -P 5037 -s emulator-5554 install -g /usr/local/lib/node_modules/appium/node_modules/io.appium.settings/apks/settings_apk-debug.apk'
 [ADB] [AVD OUTPUT] emulator: INFO: boot completed
 [ADB] [AVD OUTPUT] emulator: INFO: boot time 236743 ms
 [ADB] [AVD OUTPUT] emulator: Increasing screen off timeout, logcat buffer size to 2M.
 [ADB] [AVD OUTPUT] emulator: Revoking microphone permissions for Google App.
 [debug] [UiAutomator2] Deleting UiAutomator2 session
 [debug] [BaseDriver] Event 'newSessionStarted' logged at 1585042081970 (02:28:01 GMT-0700 (PDT))
 [debug] [MJSONWP] Encountered internal error running command: Error executing adbExec. Original error: 'Command '/usr/local/share/android-sdk/platform-tools/adb -P 5037 -s emulator-5554 install -g /usr/local/lib/node_modules/appium/node_modules/io.appium.settings/apks/settings_apk-debug.apk' timed out after 60000ms'. Try to increase the 60000ms adb execution timeout represented by 'androidInstallTimeout' capability
 [debug] [MJSONWP] Error: Command '/usr/local/share/android-sdk/platform-tools/adb -P 5037 -s emulator-5554 install -g /usr/local/lib/node_modules/appium/node_modules/io.appium.settings/apks/settings_apk-debug.apk' timed out after 60000ms
 [debug] [MJSONWP]     at Timeout.setTimeout (/usr/local/lib/node_modules/appium/node_modules/teen_process/lib/exec.js:125:19)
 [debug] [MJSONWP]     at ontimeout (timers.js:498:11)
 [debug] [MJSONWP]     at tryOnTimeout (timers.js:323:5)
 [debug] [MJSONWP]     at Timer.listOnTimeout (timers.js:290:5)
 [debug] [MJSONWP] Destroying socket connection

Disclaimer: I do mostly iOS automation.

However, I noticed you are using UiAutomator2. Have you taken a look at the UiAutomator2 specific capabilities? These might help:

https://appium.io/docs/en/writing-running-appium/caps/#uiautomator2-only

It looks like the emulator is too slow in your CI environment:

It reports

[ADB] [AVD OUTPUT] emulator: INFO: boot completed
[ADB] [AVD OUTPUT] emulator: INFO: boot time 236743 ms

way after startup detection has been completed.

You should either optimize emulator startup performance or start tests on a prebooted emulator

It is mostly the same on the prebooted emulator, I have already tried that :frowning:
So, there is no way to increase this timeout?
Then I will try to optimize someway.

There is adbExecTimeout capability. But my point is that something must be really broken there if a simple application setup takes more that one minute

My guess the machine that is used in a pipeline is just slow. However I will try to use this capability.
Thank you for your help @mykola-mokhnach!

Hi KitHat , I have the same issue because of app package name was wrong. I have corrected the app package name , then it worked well… So check ** Desired Capabilities** input.