Skip to content

Xamarin.Android 9.1.103.7

Pre-release
Pre-release
Compare
Choose a tag to compare

Xamarin.Android 9.1.103.7 was released as part of Visual Studio 2019 Preview 2.

What's New

Build and Deployment Performance Improvements

This release includes several more improvements to build and deployment times compared to Visual Studio 2017 version 15.9. For example, in a test development environment, the incremental build time after modifying one XAML page in the SmartHotel360 sample app has dropped from 8.5 seconds to 7.5 seconds and the corresponding deployment time has dropped from 5 seconds to 4.5 seconds.

See also:

  • The Build Performance Results page on the project wiki for additional comparisons and updates about the on-going work to continue to improve performance.
  • The latest numbers from the continuous integration builds.

Specific Improvements in Xamarin.Android 9.1.103.7

  • GitHub PR 2223: Optimize the default $(AssemblySearchPaths) and $(AllowedReferenceAssemblyFileExtensions) MSBuild properties by removing locations and extension types that are never used for Xamarin.Android projects. This improved the incremental build time by approximately 0.5 seconds for a test project that references 7 other Xamarin.Android projects.
  • GitHub PR 2308, GitHub PR 2320, GitHub PR 2326: Correct how several targets handle and update the timestamps of their Outputs. This prevents some scenarios where incremental builds could get stuck in a state where they would always rebuild the affected targets.
  • GitHub PR 2309: Remove unused Inputs and Outputs from several targets. This improved the total build time for those targets in a test project by a few dozen milliseconds.
  • GitHub PR 2328: Add the RegexOptions.Compiled option to a Regex and change some LINQ expressions to loops in the ConvertResourcesCases task. This improved the total time for the task in a test project by a few hundred milliseconds.
  • GitHub PR 2348: Allow the ConvertResourcesCases task to skip a specific set of "well-known" assemblies by name. For example, after this change, ConvertResourcesCases now skips all of the Xamarin.Android.Support, Xamarin.GooglePlayServices, and Xamarin.Firebase assemblies because those assemblies are built by the Xamarin team and never contain resource names that need to be converted. This can save 1 second or more for both initial clean builds and incremental builds after resource changes. The time saved depends on how many of these assemblies are used by the project.
  • GitHub PR 2384: Adjust the ResolveSdks task to cache the detected location of the JVM. This improved the incremental build time for a test project by a few hundred milliseconds.
  • GitHub PR 2394: Improve the incremental build behavior of the _ConvertPdbFiles, _CopyPdbFiles, and _CopyMdbFiles targets by correcting the Outputs so the timestamps are only updated if the contents have changed and by fixing an issue where duplicate copies of items were being added to @(FileWrites) on each build.
  • GitHub PR 2428: Save the $(AdbTarget) and $(AdbOptions) MSBuild properties in their own file rather than in the build.props file to prevent the deployment process from re-running unnecessary build targets when the deployment target has just been changed from emulator to device or from one device to another.
  • GitHub PR 2487: Change the LinkAssemblies task so that it checks for .mdb files with File.Exists() before it tries to access them. This avoids some exception handling overhead, reducing the total time for the task by a couple dozen milliseconds.
  • GitHub PR 2535: Adjust the GenerateJavaStubs and GenerateResourceDesigner tasks to perform generation and comparison in-memory rather than in temporary files, and make a few additional efficiency improvements in the GenerateJavaStubs task. This improved the initial clean build time for a test project by a few hundred milliseconds.
  • GitHub PR 2540: Adjust the ResolveLibraryProjectImports task to avoid allocating an intermediate byte[] and to avoid generating intermediate temporary files. This improved the total time for the task by a few dozen milliseconds.

App Performance Improvements

  • GitHub PR 2473: Avoid allocating or evaluating unused arguments in the primitive logging functions. This can reduce application startup time by a couple dozen milliseconds, depending on the target device.
  • GitHub PR 2500: Skip attempting to load the Java.Interop.Export.dll assembly during app startup because that part of the Java.Interop library is not used by Xamarin.Android. This can reduce application startup time by roughly 100 milliseconds, depending on the target device.

Support for the New Android DEX Compiler D8

The March 2018 release of the Android SDK introduced a new DEX compiler D8 that improves both compile times and app performance compared to the previous compiler DX. Xamarin.Android 9.2 updates the Xamarin.Android build tasks to be compatible with D8. Because D8 is not yet widely used by Xamarin.Android projects, it is not yet enabled by default. To try it with your project, set the $(AndroidDexTool) MSBuild property to d8 in your .csproj file:

<PropertyGroup>
    <AndroidDexTool>d8</AndroidDexTool>
</PropertyGroup>

For additional details about D8 in the context of Xamarin.Android, including a few comparisons of build speeds and sizes, see the integration specification notes.

Support for the New Android Code Shrinker R8

Recent versions of the Android SDK also include a preview of a new code shrinker R8 that aims to produce smaller DEX files more quickly than ProGuard. Xamarin.Android does not yet enable R8 by default. To try it with your project, set the $(AndroidLinkTool) MSBuild property to r8 in your .csproj file:

<PropertyGroup>
    <AndroidLinkTool>r8</AndroidLinkTool>
</PropertyGroup>

For additional details about R8 in the context of Xamarin.Android, including a few comparisons of build speeds and sizes, see the integration specification notes.

Enhanced Fast Deployment

Fast Deployment has historically provided faster incremental deployment times by skipping rebuilding or redeploying the Android package (APK) when there have been no changes to the AndroidManifest.xml file or to any assets, resources, shared native libraries packaged within the app, or user-defined classes that inherit from Java.Lang.Object.

Xamarin.Android 9.2 enhances fast deployment so that it now supports most of those previously unsupported scenarios except for changes to the AndroidManifest.xml file. For example, adding a new Android layout file or a new user-defined class that inherits from Java.Lang.Object now no longer require the APK to be rebuilt or redeployed.

This new enhanced fast deployment mode is not yet enabled by default in the current preview. To try it with your project, set the $(AndroidFastDeploymentType) MSBuild property to Assemblies:Dexes in your .csproj file:

<PropertyGroup>
    <AndroidFastDeploymentType>Assemblies:Dexes</AndroidFastDeploymentType>
</PropertyGroup>

For any users who might have tried the earlier experimental version of this feature introduced in Xamarin.Android 7.0, note that this new version solves the incompatibility with custom Android.App.Application subclasses and further extends the feature to cover both shared native libraries as well as classes that inherit from Java.Lang.Object.

Known Issues

  • GitHub 2608: Changes to the AndroidManifest.xml file do not yet properly trigger a rebuild of the APK.

Mono Framework Version Update to 5.18

This version of Xamarin.Android updates the Mono runtime and class libraries to Mono 5.18 Commit 23f2024a. Mono 5.18 resolves several issues in the runtime and base class libraries and imports more CoreFX implementations for types in the System.Reflection and System.Math namespaces.

Mono.Data.Sqlite SQLite Version Update

The version of SQLite used by Mono.Data.Sqlite in Xamarin.Android has been updated from 3.9.2 to 3.25.2, bringing in many improvements and bug fixes. The next Xamarin.Android 9.2 preview version will update SQLite once more to the latest version (3.26.0).

Removal of Target Framework Versions below Android 4.4 (API level 19)

As cautioned by the related build warning that was added in the Xamarin.Android 9.1 release (see GitHub PR 2329), Xamarin.Android 9.2 removes support for the v2.3, v4.0.3, v4.1, v4.2, and v4.3 values of the $(TargetFrameworkVersion) MSBuild property. Projects that have one of these old target framework versions selected will now need to change it to v4.4 or higher. The $(TargetFrameworkVersion) setting can be found in the Application section of the project properties in Visual Studio and the Build > General section of the project properties in Visual Studio for Mac.

Projects that have an old target framework selected will see the following build error until $(TargetFrameworkVersion) has been updated:

error XA0001: Unsupported or invalid $(TargetFrameworkVersion) value of 'v4.1'. Please update your Project Options.

Note that applications built against a target framework version of Android 4.4 (API level 19) or higher can still be deployed and run successfully on devices that are using Android 4.3 (API level 18) or lower. For more information, see the section about runtime checks in the guide on Android API levels.

Issues Fixed

Application and Library Build Process

  • Developer Community 400751: In Visual Studio 2019 Preview 1, projects that used comma separators with the old armeabi option in the $(AndroidSupportedAbis) MSBuild property produced a misleading "The "BuildApk" task failed unexpectedly ... Could not find a part of the path ... libmono-android.debug.so" build error rather than the expected error.
  • GitHub 1879: Using version 4.5.0 or higher of the System.Threading.Tasks.Extensions NuGet package could lead to compile errors about missing types from that library. Xamarin.Android now includes a System.Threading.Tasks.Extensions.dll facade assembly that provides the appropriate type forwarders for those types.
  • GitHub PR 2251: If the ResolveLibraryProjectImports task encountered corrupt data, it would fail with an error similar to "error MSB4018: The "ResolveLibraryProjectImports" task failed unexpectedly ... Xamarin.Tools.Zip.ZipIOException" rather than a more instructive error.
  • GitHub 2356: The ConvertResourcesCases task was running many times during builds of projects configured to use AAPT2.
  • GitHub 2360, GitHub 2361, GitHub 2362, GitHub 2363: Various lint errors could appear because the _LintChecks target was passing the whole $(IntermediateOutputPath) MSBuild property to lint. This caused lint to check files from all referenced pre-built libraries in addition to the files from the current build. The _LintChecks target now only passes the files from the current build.
  • GitHub PR 2483: Build errors about missing resources could occur in application projects configured to use AAPT2 if any of the layout files used uppercase letters in a reference to a resource from a library project.

Application Behavior on Device and Emulator

  • GitHub 2053: In Visual Studio 2019 Preview 1, apps built in the Release configuration created an unexpected .__override__ directory when run on device or emulator. Only applications built in the Debug configuration are expected to create that directory.
  • GitHub 2123: AndroidClientHandler did not yet support HTTP proxy server configuration.
  • GitHub PR 2192: Apps could fail to run on Android 6.0 (API level 23) devices if built with the $(BundleAssemblies) MSBuild property set to true.
  • GitHub 2202: The [IntentFilter] attribute was being ignored on classes decorated with a [ContentProvider] attribute.
  • GitHub PR 2480: Android assets located within subdirectories were missing from APKs in projects configured to use AAPT2 when building on Windows to due an upstream issue in aapt2. The Xamarin.Android build tasks now fix up the output from aapt2 to work around this issue.

Android API Bindings

  • Developer Community 399276: Android.Hardware.Biometrics.BiometricErrorCode was incorrectly bound as BiometricsErrorCode instead of BiometricErrorCode, resulting in a missing binding for Android.Hardware.Biometrics.BiometricPrompt.AuthenticationCallback.OnAuthenticationError(). Both types are now bound correctly.
  • GitHub 1891: The [Android.App.Activity] attribute did not include properties for all of the XML attributes for which Android Studio offers autocompletion in AndroidManifest.xml <activity/> elements. The list of properties has now been updated to include the missing items.

Design-Time Build Process

  • Developer Community 335298: Binding projects that used .aar files could cause IntelliSense errors similar to "error CS0234: The type or namespace name ... does not exist in the namespace ... (are you missing an assembly reference?)" to appear in the consuming application projects.
  • GitHub 2410: The ValidateJavaVersion task was being run during design-time builds when it did not need to run, decreasing the responsiveness of working interactively in Visual Studio.

Contributors

A big Thank You! to contributors who made improvements in this release:

  • Nathan Westfall: Add some properties to [Android.App.Activity] so that the corresponding XML attributes of <activity/> elements can now be set using [Android.App.Activity]. GitHub PR 2109
  • Yusuke Yamada: Correct mismatched XML elements in the comments of the EnumFields.xml files for several of the tests in tests/CodeGen-Binding and tests/ResolveImports. GitHub PR 2311