android: Travis-CI: error XA5300: The Android SDK Directory could not be found. Please set via /p:AndroidSdkDirectory.

Steps to Reproduce

  1. Checkout this branch
  2. Run ./build.sh

The actual msbuild command is:

msbuild /p:Configuration=Release     /p:AndroidBuildApplicationPackage=true     /t:Clean\;Build\;SignAndroidPackage     /p:AndroidSdkDirectory=/usr/local/share/android-sdk/build-tools/

That means, with or without /p:AndroidSdkDirectory= I get the same error. Ideally the error message would change once /p:AndroidSdkDirectory= is provided to indicate the parameter was correctly accepted, but the path rejected.

Expected Behavior

Builds. It does on my local macOS but it fails on Travis-CI macOS build.

Actual Behavior

On travis, even after installing all dependencies (I have a debug session attached there right now) it fails to find the Android SDK.

Log File

relevant output from diag msbuild:

Using "ResolveSdks" task from assembly "/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Build.Tasks.dll".
Task "ResolveSdks" (TaskId:66)
  Task Parameter:ReferenceAssemblyPaths=/Library/Frameworks/Mono.framework/External/xbuild-frameworks/MonoAndroid/v1.0/ (TaskId:66)
  ValidateAndroidSdkLocation: `/usr/local/share/android-sdk`, result=False (TaskId:66)
  ValidateAndroidSdkLocation: ``, result=False (TaskId:66)
  ValidateAndroidSdkLocation: `/usr/local/share/android-sdk`, result=False (TaskId:66)
  ValidateAndroidSdkLocation: `/Users/travis/Library/Android/sdk`, result=False (TaskId:66)
  ValidateAndroidNdkLocation: ``, result=False (TaskId:66)
  ValidateJavaSdkLocation: ``, result=False (TaskId:66)
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(798,2): error XA5300: The Android SDK Directory could not be found. Please set via /p:AndroidSdkDirectory. [/Users/travis/build/getsentry/sy
mbol-collector/src/SymbolCollector.Android/SymbolCollector.Android.csproj]
  Output Property: MonoAndroidToolsDirectory=/Library/Frameworks/Xamarin.Android.framework/Versions/9.4.1.0/lib/xamarin.android/xbuild/Xamarin/Android (TaskId:66)
  Output Property: MonoAndroidBinDirectory=/Library/Frameworks/Xamarin.Android.framework/Versions/9.4.1.0/lib/xamarin.android/xbuild/Xamarin/Android/Darwin/ (TaskId:66)
Done executing task "ResolveSdks" -- FAILED. (TaskId:66)
Done building target "_ResolveSdks" in project "SymbolCollector.Android.csproj" -- FAILED.: (TargetId:44)
Done Building Project "/Users/travis/build/getsentry/symbol-collector/src/SymbolCollector.Android/SymbolCollector.Android.csproj" (Clean;Build;SignAndroidPackage target(s)) -- FAILED.
Deferred Messages

The path it rejected is:

Traviss-Mac:SymbolCollector.Android travis$ ls -lah /usr/local/share/android-sdk
lrwxr-xr-x  1 travis  admin    39B Dec  5 21:48 /usr/local/share/android-sdk -> /usr/local/Caskroom/android-sdk/4333796
Traviss-Mac:SymbolCollector.Android travis$

..

Traviss-Mac:SymbolCollector.Android travis$ ls -lah /usr/local/share/android-sdk/
total 8
drwxr-xr-x@  7 travis  admin   224B Dec  5 21:50 .
drwxr-xr-x   4 travis  admin   128B Dec  5 21:48 ..
-rw-r--r--   1 travis  admin    16B Dec  5 21:50 .knownPackages
drwxr-xr-x   3 travis  admin    96B Dec  5 21:51 build-tools
drwxr-xr-x  10 travis  admin   320B Dec  5 21:50 licenses
drwxr-xr-x   3 travis  admin    96B Dec  5 21:50 platforms
drwxr-xr-x@ 14 travis  staff   448B Dec  5 21:50 tools

# there I have the tools I expect:

Traviss-Mac:SymbolCollector.Android travis$ ls -lah /usr/local/share/android-sdk/
.knownPackages  build-tools/    licenses/       platforms/      tools/
Traviss-Mac:SymbolCollector.Android travis$ ls -lah /usr/local/share/android-sdk/build-tools/
drwxr-xr-x  29 travis  staff   928B Dec  5 21:51 29.0.2

# and platform:

Traviss-Mac:SymbolCollector.Android travis$ ls -lah /usr/local/share/android-sdk/platforms/
total 0
drwxr-xr-x   3 travis  admin    96B Dec  5 21:50 .
drwxr-xr-x@  7 travis  admin   224B Dec  5 21:50 ..
drwxr-xr-x  14 travis  staff   448B Dec  5 21:50 android-29
Traviss-Mac:SymbolCollector.Android travis$

# I also have some env vars, to debug this:

Traviss-Mac:SymbolCollector.Android travis$ echo $ANDROID_SDK_ROOT
/usr/local/share/android-sdk
Traviss-Mac:SymbolCollector.Android travis$ echo $ANDROID_HOME
/usr/local/share/android-sdk

I tried creating the config file as discussed in #1481

Traviss-Mac:SymbolCollector.Android travis$ cat ~/.config/xbuild/monodroid-config.xml
<?xml version="1.0" encoding="utf-8"?>
<monodroid>
  <android-sdk path="/usr/local/share/android-sdk" />
</monodroid>

But that didn’t help. Now that I see the log diagnostic I see the path is tested by msbuild, but I’m not sure why it’s being rejected.

Version Information

Traviss-Mac:SymbolCollector.Android travis$ echo $JAVA_HOME
/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home

Traviss-Mac:SymbolCollector.Android travis$ java -version
openjdk version "1.8.0_232"
OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_232-b09)
OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.232-b09, mixed mode)

Traviss-Mac:SymbolCollector.Android travis$ dotnet --version
3.0.100

Traviss-Mac:SymbolCollector.Android travis$ mono --version
Mono JIT compiler version 6.0.0.334 (2019-02/6256b82d62f Tue Sep  3 17:44:33 EDT 2019)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
        TLS:
        SIGSEGV:       altstack
        Notification:  kqueue
        Architecture:  amd64
        Disabled:      none
        Misc:          softdebug
        Interpreter:   yes
        LLVM:          yes(600)
        Suspend:       hybrid
        GC:            sgen (concurrent by default)

Traviss-Mac:SymbolCollector.Android travis$ msbuild
Microsoft (R) Build Engine version 16.1.85+gad9c9926a7 for Mono
Copyright (C) Microsoft Corporation. All rights reserved.

Traviss-Mac:SymbolCollector.Android travis$ uname -a
Darwin Traviss-Mac.local 18.5.0 Darwin Kernel Version 18.5.0: Mon Mar 11 20:40:32 PDT 2019; root:xnu-4903.251.3~3/RELEASE_X86_64 x86_64

I’m not sure why MSBuild ignores the path /usr/local/share/android-sdk/. I’ve tried a ton of stuff and basically I can’t get this to build on Travis. Any pointers appreciated.

To certain degree it’s as #2979 although that had no detail if the path was being considered or not. With the logs here we can see msbuild takes the path, it tests it, but rejects it. I wonder what am I doing wrong. Or if there’s an issue.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 26 (26 by maintainers)

Commits related to this issue

Most upvoted comments

Release status update

A new Release version has now been published on macOS that includes the fix for this item.

Fix included in Xamarin.Android 10.2.0.100.

Fix included on macOS in Visual Studio 2019 for Mac version 8.5. To get the new version that includes the fix, check for the latest updates on the Stable updater channel.

(Fix also included on Windows in Visual Studio 2019 version 16.5 and higher. To get the new version that includes the fix, check for the latest updates or install the latest version from https://visualstudio.microsoft.com/downloads/.)

ok I managed to repo locally. The problem is that I had an sdk setup and install which it was falling back onto . I the case of Travis that is not the case. So I’ll now look at making sure we handle this particular scenario. InstallAndroidDependencies should work without anything installed.