./build.shThe 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.
Builds. It does on my local macOS but it fails on Travis-CI macOS build.
On travis, even after installing all dependencies (I have a debug session attached there right now) it fails to find the Android SDK.
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.
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.
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)
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.
@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.
@dellis1972 I've tried as you suggested:
https://github.com/getsentry/symbol-collector/compare/15d89ed88b02...8346d9849677
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?
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?
@jonathanpeppers Sorry the delay:
XamarinAndroidVersion = 9.4.1-0
I used: boots 1.0.1.386
Is that the issue? I'm targeting (or trying) API 29 everywhere:
The right branch:
https://github.com/getsentry/symbol-collector/blob/fix/travis/src/SymbolCollector.Android/SymbolCollector.Android.csproj#L19
And that's why I'm installing Android SDK build tools 29.0.2 and platforms 29:
https://github.com/getsentry/symbol-collector/blob/feat/travis/.travis.yml#L41-L42
Try including the /p:AndroidSdkDirectory argument but set it to a location within the build tree.
eg.
/p:AndroidSdkDirectory=../android-sdk
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)
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.
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".
@dellis1972 sorry I missed the "within the build tree". I tried now:
I've copied all cp -r /usr/local/share/android-sdk/* ./android-sdk/
Under the checkout dir:
Traviss-Mac:SymbolCollector.Android travis$ ls -lah ..
total 16
drwxr-xr-x 8 travis staff 256B Dec 6 16:20 .
drwxr-xr-x 15 travis staff 480B Dec 6 16:19 ..
-rw-r--r-- 1 travis staff 6.0K Dec 6 15:05 .DS_Store
drwxr-xr-x 10 travis staff 320B Dec 6 16:20 SymbolCollector.Android
drwxr-xr-x 6 travis staff 192B Dec 6 15:05 SymbolCollector.Console
drwxr-xr-x 6 travis staff 192B Dec 6 15:10 SymbolCollector.Core
drwxr-xr-x 8 travis staff 256B Dec 6 15:05 SymbolCollector.Server
drwxr-xr-x 6 travis staff 192B Dec 6 16:19 android-sdk
Traviss-Mac:SymbolCollector.Android travis$
And tried to build referring as you suggested:
msbuild -v:diag /p:Configuration=Release /p:AndroidBuildApplicationPackage=true /t:InstallAndroidDependencies\;Clean\;Build\;SignAndroidPackage /p:AndroidSdkDirectory=../android-sdk
I've also moved ../android-sdk to the current directory, and tried /p:AndroidSdkDirectory=./android-sdk.
The error message never changes.
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".
Running:
msbuild -v:diag /p:Configuration=Release /t:InstallAndroidDependencies
And:
msbuild -v:diag /p:Configuration=Release /t:InstallAndroidDependencies /p:AndroidSdkDirectory=/usr/local/share/android-sdk
Results in the same error:
"/Users/travis/build/getsentry/symbol-collector/src/SymbolCollector.Android/SymbolCollector.Android.csproj" (InstallAndroidDependencies 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]
ok, I think its because we are missing this commit on the version of Xamarin.Android you are using https://github.com/xamarin/xamarin-android/commit/008ba983fa38305284f55be9e8ea0d520d99e992. It works for me locally but I get the same problem on this project https://github.com/dellis1972/HelloForms/blob/master/.travis.yml
@dellis1972 but I have the SDK installed. Why can't it use that?
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.
@dellis1972 That'd be very nice. I'm just glad if I get to setup CI with Travis.
But I'm still no clear on way can't Xamarin pick up the Android SDK installation I did with brew. Environment variables are set correctly, etc.
that is odd. I'm investigating that now.
according to the docs android components stuff is only supported on Trusty :( https://docs.travis-ci.com/user/languages/android/#overview...
@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 :)
this is the problem https://github.com/xamarin/xamarin-android/pull/4003
@dellis1972 is that something I can override at my csproj to test it out?
@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.
Thanks a lot @dellis1972 helping troubleshoot this.
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.
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.)
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/.)