Skip to content
Latchkey

Xamarin.Android "XA5300: The Android SDK directory could not be found" in CI

Xamarin.Android builds need a path to the Android SDK. XA5300 means the build could not locate it because AndroidSdkDirectory is not set in the project or ANDROID_HOME is missing on the runner.

What this error means

A Xamarin.Android build fails with "error XA5300: The Android SDK directory could not be found. Please set its location via the 'AndroidSdkDirectory' MSBuild property."

Xamarin.Android
error XA5300: The Android SDK directory could not be found. Please set its location
via the 'AndroidSdkDirectory' MSBuild property or the ANDROID_HOME environment variable.

Common causes

ANDROID_HOME is not exported on the runner

The legacy Xamarin tasks read ANDROID_HOME/AndroidSdkDirectory; when neither is set, the SDK cannot be located.

The SDK is installed at a non-default path

The runner Android SDK lives somewhere the build does not expect, so it must be told the path explicitly.

How to fix it

Set the Android SDK path for the build

  1. Export ANDROID_HOME to the runner SDK location.
  2. Or pass AndroidSdkDirectory to MSBuild explicitly.
  3. Rebuild the Xamarin.Android project.
Terminal
export ANDROID_HOME=$ANDROID_SDK_ROOT
msbuild MyApp.Android.csproj /p:Configuration=Release /p:AndroidSdkDirectory="$ANDROID_HOME"

Install the SDK if the image lacks it

Provision the Android SDK and required platform with sdkmanager before building.

Terminal
sdkmanager "platform-tools" "platforms;android-33" "build-tools;33.0.2"

How to prevent it

  • Export ANDROID_HOME in the job environment.
  • Pass AndroidSdkDirectory when the SDK is at a custom path.
  • Provision the SDK platform and build-tools in CI.

Frequently asked questions

What causes "XA5300 Android SDK directory not found"?
The legacy Xamarin tasks read ANDROID_HOME/AndroidSdkDirectory; when neither is set, the SDK cannot be located.
How do I fix XA5300 Android SDK directory not found?
Set the Android SDK path for the build

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card