Hello Brilliant Mohapi,
Thank you for reaching out on the Microsoft Q&A portal!
The error message adb not found resulting in ##[error]PowerShell exited with code '1' occurs because your PowerShell script is trying to execute an Android Debug Bridge (adb) command, but the directory containing adb.exe is not registered in the system's PATH environment variable. Even though your logs confirm that ANDROID_HOME = C:\Android\Sdk is set, the actual adb executable resides in a specific subdirectory called platform-tools which needs to be explicitly targeted.
Here are a few ways to resolve this issue depending on your agent type:
Option 1: Switch to a Microsoft-hosted Agent (Recommended): If you are running a self-hosted agent or a custom image, the easiest way to avoid manual tool configuration is to switch your pipeline pool to use a Microsoft-hosted agent. According to the Azure Pipelines agents documentation:
"With Microsoft-hosted agents, maintenance and upgrades happen automatically. You always have the latest version of the VM image you specify in your pipeline."
The windows-latest or ubuntu-latest images already have the Android SDK and platform-tools (including adb) pre-installed and correctly mapped to the PATH.
pool:
vmImage: 'windows-latest'
Option 2: Update the PATH directly in your PowerShell Task: If you are bound to a self-hosted agent where the SDK is present at C:\Android\Sdk, you can temporarily append the platform-tools directory to the PATH inside your YAML script right before you invoke the adb commands.
- task: PowerShell@2
displayName: 'Configure Android'
inputs:
targetType: 'inline'
script: |
# Append platform-tools to the current session's PATH
$env:Path += ";C:\Android\Sdk\platform-tools"
# adb will now be recognized
adb version
# Call your actual script here:
. 'C:\automationagent_work_temp\your_script.ps1'
Option 3: Permanently update the System PATH (Self-hosted Agent): If you are managing your own self-hosted build agent, you can update the system variables so that every pipeline run natively recognizes adb:
- Log into your agent VM.
- Download the Android Command Line tools if you haven't already.
- Open Windows search, type Environment Variables, and select Edit the system environment variables.
- Under System variables, locate the
Pathvariable and click Edit. - Add the entry:
C:\Android\Sdk\platform-tools - Important: Restart the Azure Pipelines Agent service on the machine so that the runner session picks up the new environment variables.
Hope this helps! Let us know in comments if you need any further assistance.
Note: This response is drafted with the help of AI systems.