Skip to content

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

Closed

Description

@bruno-garcia

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.

Activity

  1. added
    Area: App+Library Build
    on Dec 5, 2019
  2. changed the title [-]error XA5300: The Android SDK Directory could not be found. Please set via /p:AndroidSdkDirectory.[/-] [+]Travis-CI: error XA5300: The Android SDK Directory could not be found. Please set via /p:AndroidSdkDirectory.[/+] on Dec 5, 2019
  3. added this to the Under Consideration milestone on Dec 6, 2019
  4. dellis1972 commented on Dec 6, 2019

    @dellis1972
    Contributor

    This argument

    /p:AndroidSdkDirectory=/usr/local/share/android-sdk/build-tools/
    

    I think should just be

    /p:AndroidSdkDirectory=/usr/local/share/android-sdk/
    

    i.e the root of the android-sdk rather than the build-tools. We use this property to look up files in other parts of the sdk,not just build-tools. (i.e the platforms folders, tools and platform-tools)

  5. dellis1972 commented on Dec 6, 2019

    @dellis1972
    Contributor

    Rather than having travis install the android-sdk you could try our InstallAndroidDependencies target. For example.

    msbuild Android.csproj /t:InstallAndroidDependencies /p:AndroidSdkDirectory=test-sdk /p:AcceptAndroidSDKLicenses=true
    

    This will download only the required parts of the Android SDK needed to build the app.

  6. bruno-garcia commented on Dec 6, 2019

    @bruno-garcia
    MemberAuthor

    @dellis1972

    this argument
    /p:AndroidSdkDirectory=/usr/local/share/android-sdk/build-tools/

    I've tried /usr/local/share/android-sdk/ everywhere (I'm awake this is the right path).
    When I ran out of ideas I tried to specify more specific paths like /build-tools /platforms/.

    Rather than having travis install the android-sdk you could try our InstallAndroidDependencies target. For example.

    This is really helpful! Thank you. I'll try this one out.

  7. bruno-garcia commented on Dec 6, 2019

    @bruno-garcia
    MemberAuthor

    @dellis1972 I've tried as you suggested:

    getsentry/symbol-collector@15d89ed...8346d98

    Which worked locally (I can see the deps getting installed), but on Travis, I got the same error:
    https://travis-ci.com/getsentry/symbol-collector/builds/139694092

    $ ./build.sh
    
    ~/build/getsentry/symbol-collector/src/SymbolCollector.Android ~/build/getsentry/symbol-collector
    
    Copyright (C) Microsoft Corporation. All rights reserved.
    
    Build started 12/6/2019 12:37:41 PM.
    
    Project "/Users/travis/build/getsentry/symbol-collector/src/SymbolCollector.Android/SymbolCollector.Android.csproj" on node 1 (InstallAndroidDependencies;Clean;Build;SignAndroidPackage target(s)).
    
    /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/symbol-collector/src/SymbolCollector.Android/SymbolCollector.Android.csproj]
    
    Done Building Project "/Users/travis/build/getsentry/symbol-collector/src/SymbolCollector.Android/SymbolCollector.Android.csproj" (InstallAndroidDependencies;Clean;Build;SignAndroidPackage target(s)) -- FAILED.
    

    Any other suggestion I could try?

  8. jonathanpeppers commented on Dec 6, 2019

    @jonathanpeppers
    Member

    I don't see what the Xamarin.Android version you're running on Travis. Your /v:diag log should show a XamarinAndroidVersion property, what does it print?

  9. dellis1972 commented on Dec 6, 2019

    @dellis1972
    Contributor

    Try including the /p:AndroidSdkDirectory argument but set it to a location within the build tree.
    eg.

    /p:AndroidSdkDirectory=../android-sdk
    
  10. bruno-garcia commented on Dec 6, 2019

    @bruno-garcia
    MemberAuthor

    I have. Following the advise from the error message was the first thing I did. After that was a bunch of random tries and nothing changes the error message. It's part of the issue description, I've set it as env var, I passed as a parameter, etc.

    In the description there's a diag log which shows it tested the path but it says False but not why.

    Do I have the wrong tool version? What's going on?

    Running again now (I have an SSH session again with the build agent):

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

    Still:

    "/Users/travis/build/getsentry/symbol-collector/src/SymbolCollector.Android/SymbolCollector.Android.csproj" (InstallAndroidDependencies;Clean;Build;SignAndroidPackage target) (1) ->
    (_ResolveSdks target) ->
      /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/symbol-collector/src/SymbolCollector.Android/SymbolCollector.Android.csproj]
    
        0 Warning(s)
        1 Error(s)
    
    

    Or a bigger part, which shoes the path was considered:

    Building with tools version "Current".
    Project file contains ToolsVersion="4.0". This toolset may be unknown or missing, in which case you may be able to resolve this by installing the appropriate version of MSBuild, or the build may have been for
    ced to a particular ToolsVersion for policy reasons. Treating the project as if it had ToolsVersion="Current". For more information, please see http://go.microsoft.com/fwlink/?LinkId=293424.
    Target "_GetReferenceAssemblyPaths: (TargetId:2)" in file "/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets" from project "/Users/travis/build/getsentry/symbol
    -collector/src/SymbolCollector.Android/SymbolCollector.Android.csproj" (target "_ResolveSdks" depends on it):
    Using "GetReferenceAssemblyPaths" task from assembly "Microsoft.Build.Tasks.Core, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
    Task "GetReferenceAssemblyPaths" (TaskId:2)
      Task Parameter:TargetFrameworkMoniker=MonoAndroid,Version=v1.0 (TaskId:2)
      Output Property: _XATargetFrameworkDirectories=/Library/Frameworks/Mono.framework/External/xbuild-frameworks/MonoAndroid/v1.0/ (TaskId:2)
    Done executing task "GetReferenceAssemblyPaths". (TaskId:2)
    Done building target "_GetReferenceAssemblyPaths" in project "SymbolCollector.Android.csproj".: (TargetId:2)
    Target "_ResolveSdks: (TargetId:3)" in file "/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets" from project "/Users/travis/build/getsentry/symbol-collector/src
    /SymbolCollector.Android/SymbolCollector.Android.csproj" (target "_SetLatestTargetFrameworkVersion" depends on it):
    Using "ResolveSdks" task from assembly "/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Build.Tasks.dll".
    Task "ResolveSdks" (TaskId:3)
      Task Parameter:AndroidSdkPath=../android-sdk (TaskId:3)
      Task Parameter:ReferenceAssemblyPaths=/Library/Frameworks/Mono.framework/External/xbuild-frameworks/MonoAndroid/v1.0/ (TaskId:3)
      ValidateAndroidSdkLocation: `../android-sdk`, result=False (TaskId:3)
      ValidateAndroidSdkLocation: `/Users/travis/Library/Android/sdk`, result=False (TaskId:3)
      ValidateAndroidNdkLocation: ``, result=False (TaskId:3)
      ValidateJavaSdkLocation: ``, result=False (TaskId:3)
    /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/symbol-collector/src/SymbolCollector.Android/SymbolCollector.Android.csproj]
      Output Property: _AndroidSdkDirectory=../android-sdk (TaskId:3)
      Output Property: MonoAndroidToolsDirectory=/Library/Frameworks/Xamarin.Android.framework/Versions/9.4.1.0/lib/xamarin.android/xbuild/Xamarin/Android (TaskId:3)
      Output Property: MonoAndroidBinDirectory=/Library/Frameworks/Xamarin.Android.framework/Versions/9.4.1.0/lib/xamarin.android/xbuild/Xamarin/Android/Darwin/ (TaskId:3)
    Done executing task "ResolveSdks" -- FAILED. (TaskId:3)
    Done building target "_ResolveSdks" in project "SymbolCollector.Android.csproj" -- FAILED.: (TargetId:3)
    Done Building Project "/Users/travis/build/getsentry/symbol-collector/src/SymbolCollector.Android/SymbolCollector.Android.csproj" (InstallAndroidDependencies;Clean;Build;SignAndroidPackage target(s)) -- FAILED.
    Deferred Messages
    
    Detailed Build Summary
    ======================
         (TaskId:0)
    
      ============================== Build Hierarchy (IDs represent configurations) =====================================================
      Id                  : Exclusive Time   Total Time   Path (Targets)
      ----------------------------------------------------------------------------------------------------------------------------------- (TaskId:0)
      0                   : 1.448s           1.448s       /Users/travis/build/getsentry/symbol-collector/src/SymbolCollector.Android/SymbolCollector.Android.csproj (InstallAndroidDependencies, Clean, Build, SignAndroidPackage)  (TaskId:0)
    
  11. bruno-garcia commented on Dec 6, 2019

    @bruno-garcia
    MemberAuthor

    Interestingly, the link from boots (https://aka.ms/xamarin-android-commercial-d16-4-windows) redirects to:

    Xamarin.Android.Sdk-10.1.0.30.vsix So it does look like Xamarin Android SDK 10.

  12. dellis1972 commented on Dec 6, 2019

    @dellis1972
    Contributor

    Can you try running the InstallAndroidDependencies as a separate msbuild call rather than InstallAndroidDependencies;Clean;Build?
    I found msbuild can behave oddly when calling all the targets in the same "session".

  13. 7 remaining items

  14. dellis1972 commented on Dec 7, 2019

    @dellis1972
    Contributor
  15. bruno-garcia commented on Dec 7, 2019

    @bruno-garcia
    MemberAuthor

    @dellis1972 I'm aware. build type android is a :inux box. But I need this built on macOS so I installed things myself. So the files are there, why would Xamarin not be able to find it.
    It's possible to SSH into the agent to troubleshoot if that helps.

    If I can use the switch to get it to work (will install all dependencies etc) that also does the job and we can move on but at this point I just wanted to know :)

  16. dellis1972 commented on Dec 7, 2019

    @dellis1972
    Contributor

    this is the problem #4003

  17. bruno-garcia commented on Dec 7, 2019

    @bruno-garcia
    MemberAuthor

    @dellis1972 is that something I can override at my csproj to test it out?

  18. dellis1972 commented on Dec 8, 2019

    @dellis1972
    Contributor

    @bruno-garcia I think I got it working using the script at https://github.com/journeyapps/android-sdk-installer.

    You can check out my script at https://github.com/dellis1972/HelloForms/blob/master/.travis.yml.

    I had a similar problem to you when using the script above, until I realised that it did NOT install the sdk tooling in to the root of the ./android-sdk/ directory but into a ./android-sdk/android-sdk-macosx subdirectory. This is why our tooling (which looks for adb in a specific location) did not think it was valid. I suspect you are having a similar issue, if you add a find /usr/local/share/android-sdk | grep adb to your script you might see where adb is actually being installed then use the right path. In my case it was ending up in

    ./android-sdk/android-sdk-macosx/platform-tools/adb
    

    but we were expecting it in

    ./android-sdk/platform-tools/adb
    

    which is why the path we were passing was not working.

  19. added a commit that references this issue on Dec 9, 2019
    68324d0
  20. bruno-garcia commented on Dec 10, 2019

    @bruno-garcia
    MemberAuthor

    Thanks a lot @dellis1972 helping troubleshoot this.

  21. added a commit that references this issue on Dec 12, 2019
    a963b97
  22. brendanzagaeski commented on Jan 23, 2020

    @brendanzagaeski
    Contributor

    Release status update

    A new Preview version has now been published that includes the fix for this item. The fix is not yet included in a Release version. I will update this item again when a Release version is available that includes the fix.

    Fix included in Xamarin.Android 10.2.0.84.

    Fix included on Windows in Visual Studio 2019 version 16.5 Preview 2. To try the Preview version that includes the fix, check for the latest updates in Visual Studio Preview.

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

  23. brendanzagaeski commented on Mar 17, 2020

    @brendanzagaeski
    Contributor

    Release status update

    A new Release version has now been published on Windows that includes the fix for this item. The fix is not yet published in a Release version on macOS. I will update this item again when a Release version is available on macOS that includes the fix.

    Fix included in Xamarin.Android 10.2.0.100.

    Fix included on Windows in Visual Studio 2019 version 16.5. 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/.

    (Fix also included on macOS in Visual Studio 2019 for Mac version 8.5 Preview 1 and higher. To try the Preview version that includes the fix, check for the latest updates on the Preview updater channel.)

  24. brendanzagaeski commented on Mar 24, 2020

    @brendanzagaeski
    Contributor

    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/.)

  25. ghost locked as resolved and limited conversation to collaborators on Jun 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Area: App+Library Build

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions