Appium with Python on Azure Pipelines fails with Android 35/36 emulators but works locally

Hi all,

I am trying to run Appium tests on Azure Pipelines using Python, but I am running into issues when using newer Android system images.

Environment:

  • Python: 3.13

  • Appium: 2.19

  • Appium-Python-Client: 5.2.2

  • Azure Pipelines (macOS-15)

**
What works:**

My script runs successfully on Azure Pipelines using Pixel 5 or 8 only with:
system-images;android-30;default;x86_64

What fails:On Azure Pipelines, I get failures with these Android packages:

  • - system-images;android-30;google_apis_playstore;x86_64

  • - system-images;android-35;default;x86_64

  • - system-images;android-36;google_apis_playstore;x86_64

However, locally the exact same script works fine with android-36 (so this seems to be an Azure-specific problem).

My Python script:

import time
import unittest

from appium.webdriver.webdriver import WebDriver
from appium.options.android.uiautomator2.base import UiAutomator2Options
from appium.webdriver.common.appiumby import AppiumBy
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

options = UiAutomator2Options() 
options.platform_name = 'Android' 
options.automation_name = 'uiautomator2' 
options.device_name = 'emulator-5554' 
options.app_package = 'com.android.settings'
options.app_activity = '.Settings'
options.language = 'en' 
options.locale = 'US'
options.uiautomator2_server_install_timeout = 120000
options.adb_exec_timeout = 120000   # 120s for adb commands
options.new_command_timeout = 300   # allow session idle up to 5 mins


appium_server_url = 'http://localhost:4723'


if __name__ == '__main__':

    driver = WebDriver(appium_server_url, options=options)
    print("Driver started!")
    
    driver.find_element(
    AppiumBy.ANDROID_UIAUTOMATOR,
    'new UiScrollable(new UiSelector().scrollable(true)).scrollIntoView(new UiSelector().text("Accessibility"))')

    driver.find_element(by=AppiumBy.XPATH, value='//*[@text="Accessibility"]').click()
    
    print(driver.page_source)
    
    driver.quit()

Logs:

Error from the Python script:

Traceback (most recent call last):
  File "/Users/runner/work/1/s/./.../appium/appium_android_test.py", line 58, in <module>
    driver = WebDriver(appium_server_url, options=options)
  File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/appium/webdriver/webdriver.py", line 249, in __init__
    super().__init__(
    ~~~~~~~~~~~~~~~~^
        command_executor=command_executor,
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<3 lines>...
        client_config=client_config,
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/selenium/webdriver/remote/webdriver.py", line 263, in __init__
    self.start_session(capabilities)
    ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/appium/webdriver/webdriver.py", line 342, in start_session
    response = self.execute(RemoteCommand.NEW_SESSION, w3c_caps)
  File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/selenium/webdriver/remote/webdriver.py", line 458, in execute
    self.error_handler.check_response(response)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/selenium/webdriver/remote/errorhandler.py", line 232, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: An unknown server-side error occurred while processing the command. Original error: The instrumentation process cannot be initialized within 30000ms timeout. Make sure the application under test does not crash and investigate the logcat output. You could also try to increase the value of 'uiautomator2ServerLaunchTimeout' capability
Stacktrace:
UnknownError: An unknown server-side error occurred while processing the command. Original error: The instrumentation process cannot be initialized within 30000ms timeout. Make sure the application under test does not crash and investigate the logcat output. You could also try to increase the value of 'uiautomator2ServerLaunchTimeout' capability
    at getResponseForW3CError (/Users/runner/hostedtoolcache/node/24.6.0/x64/lib/node_modules/appium/node_modules/@appium/base-driver/lib/protocol/errors.js:1143:9)
    at asyncHandler (/Users/runner/hostedtoolcache/node/24.6.0/x64/lib/node_modules/appium/node_modules/@appium/base-driver/lib/protocol/protocol.js:487:57)

##[error]Bash exited with code '1'.

I collected Appium server logs for working vs. failing cases:

Questions:

Why does this work with Android 30 default but fail with newer Android 35/36 images on Azure Pipelines?

  • Is this a compatibility issue with uiautomator2 and the newer images?

  • Is there something specific about Azure Pipelines environments that prevents uiautomator2 from launching?

  • Has anyone managed to run Appium + Python on Azure Pipelines with Android 35/36 successfully?

Any help or hints on how to debug or fix this would be much appreciated!