Xamarin.Android 7.2

Xamarin.Android 7.2: Yay, fixes!

OSS Core

Xamarin.Android 7.0 is the first release to use the open-source repositories:

System Requirements

Xamarin.Android 7.1 requires JDK 1.8 to use the Android Nougat (API 24) APIs. Using the Android build-tools r24+ package may also require using JDK 1.8. You can continue to use earlier versions of the JDK when using earlier build-tools packages and when targeting earlier Android API levels:

Additionally, a 64-bit version of the JDK is required to use custom controls in the Android designer.

The simplest option is to install the 64-bit version of JDK 1.8 since it is backwards compatible with all of the previous API levels and supports the new Android designer features.

(One unfortunate complication with JDK 1.8 is that is not compatible with the outdated version of Proguard that is included in the Android SDK. Currently this will cause an error "Unsupported class version number [52.0]" when attempting to use the Proguard or Multidex features in Xamarin.Android. See 44187.)

Vulkan Support

Android v7.0 Nougat adds support for the Vulkan API. Vulkan support will not be distributed as part of the core Xamarin.Android binding. Instead, please use the VulkanSharp NuGet package, and the XLogo sample app.

Native Library Use

Due to a change by Google, Android N will now only permit linking to NDK-provided native libraries. libsqlite.so is not an NDK-provided native library. Consequently, existing apps using e.g. Mono.Data.Sqlite.dll will crash when running on Android N. This may include other SQLite-using assemblies, not distributed with Xamarin.Android.

Xamarin.Android 7.0, which is part of Cycle 8, updates Mono.Data.Sqlite.dll to include a custom built version of libsqlite.so, named libsqlite3_xamarin.so.

All Developers need to audit their code for P/Invoke and ensure that referenced native libraries are either included in the Android NDK, or are included within the app.apk itself. The only Xamarin.Android-provided assembly impacted by this change is Mono.Data.Sqlite.dll.

Known Issues

Xamarin.Android changed the default GC Bridge from old to tarjan.

Unfortunately, a few bugs have been reported which suggest a bug within the Tarjan GC bridge.

If this happens, create an @(AndroidEnvironment) file and add the following line:

MONO_GC_PARAMS=bridge-implementation=old

This will cause the app to use the previous GC bridge.

Xamarin.Android 7.2

The Xamarin.Android 7.2 release primarily includes bug fixes.

New Features

  • Bueller?

Experimental Features

Xamarin.Android 7.0 introduces several experimental features, which are still experimental:

TLS 1.2 support in WebRequest

Xamarin.Android 7.1 added AndroidClientHandler, which uses the native Java APIs to provide TLS 1.2 support. However, there are two problems with AndroidClientHandler:

  1. It can only be used with HttpClient, and
  2. It requires Android 5.0 and later to operate. (Prior Android versions might not support TLS 1.2, and since AndroidClientHandler uses the native Java TLS stack...)

To solve these problems, Boring SSL can be used as the lowest-level TLS implementation. Originally announced last September, Boring SSL can be embedded within a Xamarin.Android application, allowing HttpWebRequest to communicate with TLS 1.2 endpoints. When enabled, the normal HttpClient stack also uses Boring SSL.

To enable use of BoringSSL, add the $(AndroidTlsProvider) MSBuild property to the application project, with a value of btls:

<PropertyGroup>
  <AndroidTlsProvider>btls</AndroidTlsProvider>
</PropertyGroup>

When enabled, a new libmono-btls-shared.so shared library will be present within the .apk.

The default value of the $(AndroidTlsProvider) MSBuild property is the empty string, i.e. not set, which will use the managed TLS implementation, which does not support TLS 1.2.

The default value may change in a future release.

Concurrent GC Support

The new $(AndroidEnableSGenConcurrent) MSBuild property which controls whether or not the concurrent GC is enabled.

$(AndroidEnableSGenConcurrent) is a boolean value. When True, then Mono's GC is set to marksweep-conc; when False, then Mono's GC is set to marksweep.

The default value is False.

See Mono's ConcurrentSGen documentation for more information.

Improved Fast Deployment

Fast Deployment is a way to avoid rebuilding and redeploying Android Packages (.apk files) when assemblies have changed in a way that doesn’t require changing the generated Android Callable Wrappers or altered any included Android Assets and Resources.

Xamarin.Android 7.0 will optionally allow Android Assets, Resources, and compiled Java libraries to particpate in fast deployment as well, further reducing the number of situations in which a possibly slow .apk rebuild and redeploy will be required.

This new behavior is disabled by default. It will be enabled by default in the Xamarin.Android 7.1 series.

To enable this new functionality, set the $(AndroidFastDeploymentType) MSBuild property to Assemblies:Dexes:

<AndroidFastDeploymentType>Assemblies:Dexes</AndroidFastDeploymentType>

Adding Resources to the Default Project

For example, assume a new (default) Application project which has already been deployed to a target device.

  1. Copy Resources\layout\Main.axml to Resources\layout\Another.axml, and add Resources\layout\Another.axml to the project.
  2. Run the project.

(2) will require that the .apk be rebuilt and re-deployed to the target. In previous versions, (2) could take 16 seconds.

With the new system

TODO:

Add some small benchmarks about what happens during dev when code changes, or a resource changes, numbers before/after

Workflow Changes

The mcw-gen/mcw-gen.exe utility is deprecated and will not be provided in future releases.

We believe that this won't actually break anybody, because as far as we can tell nobody was ever actually using that utility.

Known Issues

Bug Fixes

  • 5979: List support in generic method instantiation in binding got broken by JavaObjectExtensions.JavaCast()
  • 43513: Android Binding Adding Generic Arg where one does not exist
  • 44673: AndroidClientHandler ignores Timeout value and CancellationToken
  • 46397: Xamarin.Forms build failed with "Error executing task ResolveAssemblies: Out of memory"
  • 46454: need to escape C# keywords in some parameter reference
  • 46931: 'Error: no package specified' message with 7.0.2.37
  • 48016: System.Net.NetworkInformation.DnsAddresses is always empty. Fix included.
  • 48508: Archiving Android application is archiving old builds
  • 48678: NDK r12b+ is not supported
  • 51356: Unable to run Multi-Dex
  • 51480: Improved fast deployment doesn't build my app
  • 51774: AndroidClientHandler throws NetworkOnMainThreadException on Cancelation via cancelation delegate call
  • 51175: Fallback to portable pdb with roslyn doesn't work if csproj is missing <DebugType>
  • 52259: XA depends on random source file from the mono tree that is gone on master

Integrated Mono Features/Fixes

Xamarin.Android uses Mono 4.8 commit e464ddae.

  • 46929: Datetime error on Mono.data.Sqlite
  • 52437: Random NullReferenceExceptions in StringBuilder.ThreadSafeCopy
  • 52590: Cannot compile for iOS, TypeBuilder exists in two places.
  • 52845: [Cycle 9] Satellite assemblies not bundled when using "Bundle assemblies into native code" due to "unknown escape sequence" error from gcc during mkbundle step
  • 53066: Can't Build Project in Debug with "Could not AOT the assembly"

API Changes

TODO

Xamarin Workbook

If it's not already installed, install the Xamarin Workbooks app first. The workbook file should download automatically, but if it doesn't, just click to start the workbook download manually.