Xamarin-android: AndroidSdkBuildToolsVersion 30+ and Java 11 inconsistency

Created on 21 Oct 2020  路  10Comments  路  Source: xamarin/xamarin-android

Steps to Reproduce

  1. Install 30+ build tools in sdk manager.

2A. Specify AndroidSdkBuildToolsVersion with 30+ value in csproj.
2B. Don't specify AndroidSdkBuildToolsVersion in csproj.

  1. Build

Expected Behavior

Consistent behaviour for build with AndroidSdkBuildToolsVersion property and without it for the effectively same value.

Actual Behavior

For 2a) scenario there is an error on the very early stage of the build:

/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Legacy.targets(5,5): Error XA0032: Java SDK 11.0 or above is required when using Android SDK Build-Tools 30.0.2. (XA0032) (ApacheHttp)

from ValidateJavaVersion in Xamarin.Android.Legacy.targets

For 2b) scenario works without any errors and correctly chooses the latest build tools 30+ available

Task "ResolveAndroidTooling"
    Trying build-tools path: /Users/USER/Library/Developer/Xamarin/android-sdk-macosx/build-tools/30.0.2
    Using cached value for Aapt2Version: 2.19
    ResolveAndroidTooling Outputs:
      AndroidApiLevel: 30
      AndroidApiLevelName: 30
      AndroidSdkBuildToolsPath: /Users/USER/Library/Developer/Xamarin/android-sdk-macosx/build-tools/30.0.2
      AndroidSdkBuildToolsBinPath: /Users/USER/Library/Developer/Xamarin/android-sdk-macosx/build-tools/30.0.2
      ZipAlignPath: /Users/USER/Library/Developer/Xamarin/android-sdk-macosx/build-tools/30.0.2
      AndroidSequencePointsMode: None
      LintToolPath: /Users/USER/Library/Developer/Xamarin/android-sdk-macosx/tools/bin
      ApkSignerJar: /Users/USER/Library/Developer/Xamarin/android-sdk-macosx/build-tools/30.0.2/lib/apksigner.jar
      AndroidUseApkSigner: True
      AndroidUseAapt2: True
      Aapt2Version: 2.19
      TargetFrameworkVersion: v11.0
  Done executing task "ResolveAndroidTooling".

So the question is if Xamarin.Android.Legacy.targets checks for some legacy conditions that are not valid anymore because build tools 30+ are supported or 30+ build tools are still not supported and it works only by chance?

Looking into the latest https://github.com/xamarin/xamarin-android-tools/blob/master/src/Xamarin.Android.Tools.AndroidSdk/Xamarin.Android.Tools.Versions.props#L12 it seems that 30.0.2 is the latest officially bumped version so 30+ tools are supported.

Is this note still valid https://github.com/xamarin/xamarin-android/blob/380e95e340168f68b1ae3eb43e0a71b05bc6d80b/Documentation/release-notes/4567.md ?

Version Information

=== Visual Studio Enterprise 2019 for Mac ===

Version 8.7.8 (build 4)
Installation UUID: 4a2a7fd4-4323-44d7-8285-fd367a0131d6
GTK+ 2.24.23 (Raleigh theme)
Xamarin.Mac 6.18.0.23 (d16-6 / 088c73638)

Package version: 612000093

=== Mono Framework MDK ===

Runtime:
Mono 6.12.0.93 (2020-02/620cf538206) (64-bit)
Package version: 612000093

=== Roslyn (Language Service) ===

3.7.0-6.20427.1+18ede13943b0bfae1b44ef078b2f3923159bcd32

=== NuGet ===

Version: 5.7.0.6702

=== .NET Core SDK ===

SDK: /usr/local/share/dotnet/sdk/3.1.403/Sdks
SDK Versions:
3.1.403
3.1.402
3.1.401
3.1.302
3.1.301
3.1.300
3.1.200
3.1.102
3.1.101
3.1.100
3.1.100-preview3-014645
3.0.100
2.1.810
MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/6.12.0/lib/mono/msbuild/Current/bin/Sdks

=== .NET Core Runtime ===

Runtime: /usr/local/share/dotnet/dotnet
Runtime Versions:
3.1.9
3.1.8
3.1.7
3.1.6
3.1.5
3.1.4
3.1.2
3.1.1
3.1.0
3.1.0-preview3.19553.2
3.0.0
2.1.22
2.1.21
2.1.20
2.1.19
2.1.18
2.1.16
2.1.15
2.1.14
2.1.13

=== Xamarin.Profiler ===

Version: 1.6.12.29
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

=== Updater ===

Version: 11

=== Xamarin.Android ===

Version: 11.0.2.0 (Visual Studio Enterprise)
Commit: xamarin-android/d16-7/025fde9
Android SDK: /Users/USER/Library/Developer/Xamarin/android-sdk-macosx
Supported Android versions:
7.0 (API level 24)
8.0 (API level 26)

SDK Tools Version: 26.1.1
SDK Platform Tools Version: 30.0.4
SDK Build Tools Version: 30.0.2

Build Information:
Mono: 83105ba
Java.Interop: xamarin/java.interop/d16-7@1f3388a
ProGuard: Guardsquare/proguard/proguard6.2.2@ebe9000
SQLite: xamarin/sqlite/3.32.1@1a3276b
Xamarin.Android Tools: xamarin/xamarin-android-tools/d16-7@017078f

=== Microsoft OpenJDK for Mobile ===

Java SDK: /Users/USER/Library/Developer/Xamarin/jdk/microsoft_dist_openjdk_1.8.0.25
1.8.0-25
Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

=== Android SDK Manager ===

Version: 16.7.0.13
Hash: 8380518
Branch: remotes/origin/d16-7~2
Build date: 2020-09-16 05:12:24 UTC

=== Android Device Manager ===

Version: 16.7.0.24
Hash: bb090a3
Branch: remotes/origin/d16-7
Build date: 2020-09-16 05:12:46 UTC

=== Apple Developer Tools ===

Xcode 11.7 (16142)
Build 11E801a

=== Xamarin.Mac ===

Xamarin.Mac not installed. Can't find /Library/Frameworks/Xamarin.Mac.framework/Versions/Current/Version.

=== Xamarin.iOS ===

Version: 14.0.0.0 (Visual Studio Enterprise)
Hash: 7ec3751a1
Branch: xcode12
Build date: 2020-09-16 11:33:15-0400

=== Xamarin Designer ===

Version: 16.7.0.495
Hash: 03d50a221
Branch: remotes/origin/d16-7-vsmac
Build date: 2020-08-28 13:12:52 UTC

=== Build Information ===

Release ID: 807080004
Git revision: 9ea7bef96d65cdc3f4288014a799026ccb1993bc
Build date: 2020-09-16 17:22:54-04
Build branch: release-8.7
Xamarin extensions: 9ea7bef96d65cdc3f4288014a799026ccb1993bc

=== Operating System ===

Mac OS X 10.15.7
Darwin 19.6.0 Darwin Kernel Version 19.6.0
Mon Aug 31 22:12:52 PDT 2020
root:xnu-6153.141.2~1/RELEASE_X86_64 x86_64

Log File

App+Library Build bug

Most helpful comment

In case it's handy since by chance I noticed this discussion, another way to think about it is that the current "go-live" (for use in production) recommendation would be the version used in the latest Release branch. The current Release branch would be xamarin-android-tools/d16-7 and xamarin-android/d16-7. In those branches, the default Android SDK Build-Tools version is 29.0.2: https://github.com/xamarin/xamarin-android/blob/d16-7/Configuration.props#L101

For the Preview versions, note that the Android SDK Platform-Tools version is different from the Android SDK Build-Tools version. The Android SDK Build-Tools version is still set to 29.0.2, even in Visual Studio 2019 version 16.8 Preview 5 and Visual Studio 2019 for Mac version 8.8 Preview 5:

https://github.com/xamarin/xamarin-android-tools/blob/d16-8/src/Xamarin.Android.Tools.AndroidSdk/Xamarin.Android.Tools.Versions.props#L12

All 10 comments

@awattar if you don't have the exact build-tools version that Xamarin.Android prefers, I could see the existing code could auto-select a build-tools 30.x.

I think #5231 will fix your problem, but you should probably uninstall any build-tools 30.x until that lands in a release.

@jonathanpeppers thanks for the info - I was suspecting it works this way (auto-select) after one of the "latest" changes in this area and it was working pretty well ;)

So what about https://github.com/xamarin/xamarin-android-tools/blame/26d65d95943b18bb9575d75c8c60ce36180a0db9/src/Xamarin.Android.Tools.AndroidSdk/Xamarin.Android.Tools.Versions.props#L12 ?

It seems that 30.0.2 is the currently preferred version.

It seems that 30.0.2 is the currently preferred version.

We've been reworking how this works. Eventually xamarin-android-tools will be the source of truth here.

I don't think this new Xamarin.Android.Tools.Versions.props file will take effect until some future VS Mac 8.9 or VS Windows 16.9 release.

I see. Thanks - was hoping it was included in the latest preview as it states that platform-tools were updated to 30.0.4

image

which is also the latest change in the props file https://github.com/xamarin/xamarin-android-tools/blame/26d65d95943b18bb9575d75c8c60ce36180a0db9/src/Xamarin.Android.Tools.AndroidSdk/Xamarin.Android.Tools.Versions.props#L14

We'll see what happens by the time 8.8/16.8 goes GA. I think they are right now trying to align all the products that are all owned by different teams: IDEs, installers, Xamarin.Android itself, etc. Things might change -- or might not.

In case it's handy since by chance I noticed this discussion, another way to think about it is that the current "go-live" (for use in production) recommendation would be the version used in the latest Release branch. The current Release branch would be xamarin-android-tools/d16-7 and xamarin-android/d16-7. In those branches, the default Android SDK Build-Tools version is 29.0.2: https://github.com/xamarin/xamarin-android/blob/d16-7/Configuration.props#L101

For the Preview versions, note that the Android SDK Platform-Tools version is different from the Android SDK Build-Tools version. The Android SDK Build-Tools version is still set to 29.0.2, even in Visual Studio 2019 version 16.8 Preview 5 and Visual Studio 2019 for Mac version 8.8 Preview 5:

https://github.com/xamarin/xamarin-android-tools/blob/d16-8/src/Xamarin.Android.Tools.AndroidSdk/Xamarin.Android.Tools.Versions.props#L12

Thanks guys was assuming that something has slipped into the latest preview especially it works for 30+ build tools in auto select scenario. I know platform and build tools difference but since platform was updated to 30.0.4 I was assuming that the build tools could be also updated.

Everything is clear now.

Yeah, that change for the default Platform-Tools version in the 16.8 Preview 5 and 8.8 Preview 5 versions was definitely tricky because it didn't update the default Build-Tools version at the same time. I'll plan to add an extra sentence in that section of the release notes before the final 16.8 and 8.8 Release versions to clarify that the default Build-Tools version is still set to 29.0.2 in Xamarin.Android 11.1 (the d16-8 branch).

Brilliant!

Was this page helpful?
0 / 5 - 0 ratings