Skip to content

Conversation

@dellis1972
Copy link
Contributor

This commit is part of an effort to make sure all of our tooling uses
the same android sdk versions. It adds a MSbuild .props file
which contains the versions of parts of the Android Sdk. It is
these versions which will be installed/used by default when a
user first installs the product, or if they do not specify
other versions in their csproj.

If the new file is changed ALL repos referencing this one
will need to be updated. This includes all repos which pull
in this one via androidtools.

@dellis1972 dellis1972 requested a review from jonpryor July 1, 2020 09:26
@dellis1972
Copy link
Contributor Author

failure does not look related.

X Ndk_PathInSdk [150ms]
  Error Message:
     AndroidNdkPath not found inside sdk!
  Expected string length 71 but was 53. Strings differ at index 3.
  Expected: "C:\\Users\\VssAdministrator\\AppData\\Local\\Temp\\tmp4A25.tmp\\sdk\\..."
  But was:  "C:\\Program Files (x86)\\Android\\android-sdk\\ndk-bundle"

@dellis1972
Copy link
Contributor Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@jonpryor
Copy link
Contributor

jonpryor commented Jul 1, 2020

This should also add a $(AndroidCommandLineToolsVersion) value, a'la:

https://github.com/xamarin/xamarin-android/blob/master/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.props.in#L12

This commit is part of an effort to make sure all of our tooling uses
the same android sdk versions. It adds a MSbuild `.props` file
which contains the versions of parts of the Android Sdk. It is
these versions which will be installed/used by default when a
user first installs the product, or if they do not specify
other versions in their `csproj`.

If the new file is changed ALL repos referencing this one
will need to be updated. This includes all repos which pull
in this one via `androidtools`.
@jonpryor jonpryor merged commit a6a23bb into dotnet:master Jul 1, 2020
jonpryor pushed a commit that referenced this pull request Jul 1, 2020
Context: https://issuetracker.google.com/issues/150189789
Context: https://github.com/xamarin/androidtools/commit/3f51412d5f213c0267fc597623f3430437d6452e

We have discovered an issue when installing Visual Studio for Mac
on macOS: certain versions of the installer will install the *latest*
Android SDK Build-tools package, currently r30.0.0.

This is a problem because recent versions of Xamarin.Android will use
`apksigner` to sign `Mono.Android.Platform.ApiLevel_*.apk` files, so
that they can be installed on API-30 targets -- API-30 targets no
longer like `jarsigner`-signed `.apk` files -- but the `apksigner`
included in the Build-tools r30 package requires JDK 9.

Visual Studio for Mac is not ready to migrate to JDK >= 9.

Consequently, on such installation environments, the Xamarin.Android
shared runtime cannot be created, as `apksigner` won't run:

	Exception in thread "main" java.lang.UnsupportedClassVersionError: com/android/apksigner/ApkSignerTool
	has been compiled by a more recent version of the Java Runtime (class file version 53.0),
	this version of the Java Runtime only recognizes class file versions up to 52.0

What we need is a way for the macOS installer to share the same
[default Android SDK component versions as Xamarin.Android itself][0].

This *could* plausibly be done by adding a git submodule reference from
the xamarin/xamarin-android repo to the macOS installer, but this is
undesirable.

Instead, both the the xamarin-android repo and the installer repo's
have existing git submodules graphs which include the
xamarin/xamarin-android-tools repo.

Add a new `Xamarin.Android.Tools.Versions.props` file, which contains
the default Android SDK component versions, as an MSBuild project file:

	<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
	   <PropertyGroup>
	     <AndroidSdkBuildToolsVersion Condition="'$(AndroidSdkBuildToolsVersion)' == ''">29.0.2</AndroidSdkBuildToolsVersion>
	     …

With this file in place, we can update the macOS installer to use
`Xamarin.Android.Tools.Versions.props` as the "source of truth" for
which versions to install.  In particular, we'll set the default
Build-tools version to 29.0.2, *not* 30.0.0, thus avoiding the problem
with `apksigner` invocations.

In the future, when `Xamarin.Android.Tools.Versions.props` is changed
*all* repos referencing xamarin/xamarin-android-tools will need to be
updated, so that everything can be on the same "page".

[0]: https://github.com/xamarin/xamarin-android/blob/5f78740d74e19b235aad62c8ea8e314c9c78ddce/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.props.in#L18-L21
jonpryor pushed a commit that referenced this pull request Jul 1, 2020
Context: https://issuetracker.google.com/issues/150189789
Context: https://github.com/xamarin/androidtools/commit/3f51412d5f213c0267fc597623f3430437d6452e

We have discovered an issue when installing Visual Studio for Mac
on macOS: certain versions of the installer will install the *latest*
Android SDK Build-tools package, currently r30.0.0.

This is a problem because recent versions of Xamarin.Android will use
`apksigner` to sign `Mono.Android.Platform.ApiLevel_*.apk` files, so
that they can be installed on API-30 targets -- API-30 targets no
longer like `jarsigner`-signed `.apk` files -- but the `apksigner`
included in the Build-tools r30 package requires JDK 9.

Visual Studio for Mac is not ready to migrate to JDK >= 9.

Consequently, on such installation environments, the Xamarin.Android
shared runtime cannot be created, as `apksigner` won't run:

	Exception in thread "main" java.lang.UnsupportedClassVersionError: com/android/apksigner/ApkSignerTool
	has been compiled by a more recent version of the Java Runtime (class file version 53.0),
	this version of the Java Runtime only recognizes class file versions up to 52.0

What we need is a way for the macOS installer to share the same
[default Android SDK component versions as Xamarin.Android itself][0].

This *could* plausibly be done by adding a git submodule reference from
the xamarin/xamarin-android repo to the macOS installer, but this is
undesirable.

Instead, both the the xamarin-android repo and the installer repo's
have existing git submodules graphs which include the
xamarin/xamarin-android-tools repo.

Add a new `Xamarin.Android.Tools.Versions.props` file, which contains
the default Android SDK component versions, as an MSBuild project file:

	<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
	   <PropertyGroup>
	     <AndroidSdkBuildToolsVersion Condition="'$(AndroidSdkBuildToolsVersion)' == ''">29.0.2</AndroidSdkBuildToolsVersion>
	     …

With this file in place, we can update the macOS installer to use
`Xamarin.Android.Tools.Versions.props` as the "source of truth" for
which versions to install.  In particular, we'll set the default
Build-tools version to 29.0.2, *not* 30.0.0, thus avoiding the problem
with `apksigner` invocations.

In the future, when `Xamarin.Android.Tools.Versions.props` is changed
*all* repos referencing xamarin/xamarin-android-tools will need to be
updated, so that everything can be on the same "page".

[0]: https://github.com/xamarin/xamarin-android/blob/5f78740d74e19b235aad62c8ea8e314c9c78ddce/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.props.in#L18-L21
@dellis1972 dellis1972 deleted the addtoolsprops branch July 2, 2020 09:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants