Xamarin.Android 7.1

Xamarin.Android 7.1: 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:


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

Xamarin.Android 7.1.0-43

(We forgot to bump the micro version. Oops.)

Integrated Mono Features/Fixes

Xamarin.Android uses Mono 4.8 commit 8f6d0f67.

  • 46929: Datetime error on Mono.data.Sqlite
  • 52437: Random NullReferenceExceptions in StringBuilder.ThreadSafeCopy
  • 52590: Cannot compile for iOS, TypeBuilder exists in two places.
  • 52845: 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"

Xamarin.Android 7.1

The Xamarin.Android 7.1 release primarily includes bug fixes.

New Features

Linker Improvements

Previously, if all type references to a given assembly were removed, the assembly reference would remain. Starting in Xamarin.Android 7.1, the assembly reference will be removed.

For example, System.dll contains a reference to System.Xml.Serialization.XmlIgnoreAttribute, located in System.Xml.dll. If XmlIgnoreAttribute isn't used by the application, the type reference within System.dll will be removed.

However, in Xamarin.Android 7.0 and prior releases, even though there there may be no remaining references to System.Xml.dll, System.Xml.dll would still be packaged and distributed within the application package (.apk file).

Starting in Xamarin.Android 7.1, in this scenario System.dll will be modified to no longer contain an assembly reference to System.Xml.dll, allowing System.Xml.dll to be removed from the package.

This change should result in smaller application packages without breaking compatibility.

However, if an assembly was being loaded dynamically, for example through Assembly.Load("System.Xml"), then an exception may now be thrown. If this is the case, you can use the $(AndroidLinkSkip) MSBuild property to explicitly preserve the referenced assembly.

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:


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.

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:


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


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

Known Issues

Bug Fixes

  • 37263: Preserve application data no longer works
  • 37491: App crashes in Release config on device with System.Runtime.Serialization.InvalidDataContractException
  • 42091: Latest update breaks InputJar bindings
  • 42366: Exception doesn't include Java native stacktrace anymore
  • 43287: System modal windows during release build
  • 44447: Android symbolication uses wrong property
  • 44531: [Generator] new error CS0533: $(CHILD) hides inherited abstract member from $(PARENT)
  • 44961: AndroidClientHandler throws NetworkOnMainThreadException
  • 45137: Seeing new AAPT0000 errors when building certain projects against master
  • 45311: Bug in constructor of AndroidHttpResponseMessage
  • 46344: Unhandled Exception in class-parse when processing nested generic types.
  • 48508: Archiving Android application is archiving old builds
  • 51356: Unable to run Multi-Dex

Breaking Changes

Removal of interface default methods in API-24

API-24 introduced support for Java 1.8 and a number of new Java language features such as interface default methods.

Interface default methods were originally bound as "normal" interface methods, which resulted in many interface bindings containing methods that, in retrospect, we feel shouldn't be there.

We feel that this breakage is acceptable because:

  1. It only impacts API-24, which at present is used on 0.3% of Android devices.

  2. Only impacts 3 interfaces: Java.Util.IPrimitiveIteratorOfDouble, Java.Util.IPrimitiveIteratorOfInt, and Java.Util.IPrimitiveIteratorOfLong.

  3. The above interfaces are extremely unlikely to be implemented by anyone.

Integrated Mono Features/Fixes

Xamarin.Android uses Mono 4.8 commit ed0fb9de.

  • 5644: Mono allows to access not accessible method
  • 7467: DefaultNonPersistentConnectionLimit is to low
  • 12571: Usage of XElement with XmlAnyElementAttribute is not supported by XmlSerializer
  • 19594: WebException.Response is null when https request needs proxy authentication
  • 29189: Compiling class referencing corefx facade/contract assemblies raises error "Reference to type System.SByte' claims it is defined assemblymscorlib,..` but couldn't be found"
  • 30146: stack imbalance in DllImport with CallingConvention.StdCall
  • 30686: ZipArchive ctor throws InvalidDataException for WebConnectionStream
  • 30821: Compilation generates CS1701 warning
  • 32374: WebRequest::BeginGetRequestStream incorrectly sets IAsyncResult::CompletedSynchronously to always true
  • 33571: Mono crashes when marshalling fixed arrays
  • 34715: HttpClient incorrectly works with multiple headers
  • 34802: Debugger crash on break-all, step into sequence.
  • 35536: Dns.GetHostEntry no longer supports IPv6
  • 35662: Type System.ServiceModel.Security.Tokens.BinarySecretSecurityToken is missing in assembly System.IdentityModel
  • 38025: "Step Out" gets confused by nested code
  • 39282: [System.IO.Compression] issues with ZipArchiveEntry streams
  • 39832: SIGSEGV when running roslyn
  • 39859: Xamarin.Android apps on the Samsung Galaxy S7 fails to start with the error System.ExecutionEngineException SIGILL
  • 40603: Mono can't parse Date in DB wich is in format: "2016-02-04 10:39:11Z"
  • 40916: [System.IO.Compression] ZipArchive can create an ZipArchiveEntry that has a modified time of DateTime.MinValue
  • 41133: System.MethodAccessException: Method System.Net.WebHeaderCollection:AddValue (string,string) is inaccessible from method System.Net.Http.HttpClientHandler
  • 41035: DataViewTest2.DataView_ListChangedEventTest occasionally fails with llvm+sgen
  • 41349: System.TimeZoneInfo.IsDaylightSavingTime (DateTimeOffset dateTimeOffset) Not Implemented Exception
  • 41393: [WatchOS 2] Incorrect calling convention for P/Invokes taking structures
  • 41431: [aot] Build fails due to 'Sgen STW requires a working mono-context' error
  • 41466: monoclassissubclassof return incorrect value by assuming monoclassinit has been called on parameters
  • 41477: SafeSocketHandle ObjectDisposedException 'handle' exception with linked CancellationTokenSource
  • 41492: DateTimeOffset.ToLocalTime() throwing erroneous error
  • 41509: DLR crashes when trying to convert a object to null.
  • 41530: [iOS]TimerTest failing randomly on devices,
  • 41552: HttpResponseMessage does not support multiple Links header entries
  • 41575: A Method That Accepts a FormattableString Object Is Not Called
  • 41602: Compiler fails to recognize Indexer
  • 41616: Mono 4.4.0 crashes when using Socket.ConnectAsync to a unix domain socket if the path doesn't exist
  • 41623: "Step Over" on an Android App deployed to a physical/virtual device crashes the app
  • 41667: new DateTime().ToLocalTime() results in an exception
  • 41705: MonoTests.System.Threading.MonitorTest.Enter_Null crashes test runtime with assertion
  • 41775: Zip version needed to extract not correct in System.IO.Compression
  • 41782: [Cycle 7] "System.Net.WebException: Error: NameResolutionFailure" when attempting web requests with certain raw IP addresses
  • 41786: Mono is broken when building with the macOS 10.12 SDK
  • 41833: [SGEN?] XS crashed. error: * Assertion at gc.c:867, condition `finalizerthreadexited' not met
  • 41874: Reflection throws AmbiguousMatchException when calling GetProperty on a class that inherits from a generic base class.
  • 41897: NotSupportedException thrown from IPInterfaceProperties.UnicastAddresses
  • 41937: invoke.exe test asserts on bitcode
  • 41955: Bitcode "missing image did not probe corlib" exception thrown
  • 41979: CodeDom cannot call mcs because of invalid encoding configuration
  • 42057: error CS0121: The call is ambiguous
  • 42169: (managed_alloc) Fatal: Managed allocator missing for (mkbundle) in Mono 4.4.X
  • 42191: sdb deadlocks all the time while XS debugs XS
  • 42198: error CS0529: Inherited interface causes a cycle in the interface hierarchy.
  • 42219: [System.IO.Compression] Cannot create ZipArchive with duplicate entries with same name
  • 42224: Compiler crashed with code: 1, "Await yields with non-empty stack" from AssertEmptyStack ()
  • 42226: WCF client Expecting FaultException<TDetail> raising NotImplemented Exception instead When <FaultActor> element is provided.
  • 42271: COOP: gc unsafe mode when printing native backtrace causes crash if GC is triggered
  • 42274: System.IO.Compression.ZipArchive vs System.Xml.XmlReader
  • 42395: Build runs indefinitely and never finishes
  • 42408: WebClient.DownloadString returns 401 Unauthorized when using Basic authentication
  • 42410: String Interpolation available even when langversion < 6
  • 42413: Volatile fields don't enforce acquire - release semantics like Volatile.Read() and Volatile.Write()
  • 42584: InternalError / Crash when using System.Net.Http and PCL library
  • 42585: Switch fall-through not rejected
  • 42611: wrong compiler error when using IEnumerable.Sum
  • 42625: coop: crash with watchos system tests
  • 42688: Can't wait for more than 429496 ms (429s)
  • 42702: Unnecessary dependency checks
  • 42750: Deploying an iOS app to iPhone 6S crashes when a breakpoint is set
  • 42843: XmlSerializer does not deserialize UTC Time values on Xamarin.Android but works well on windows.
  • 42864: [Cycle 7] "System.Net.WebException: Error: NameResolutionFailure" on second web request to certain raw IP addresses with HttpClient
  • 42887: Encoding iso-8859-1 throws IndexOutOfRangeException for Unicode surrogate pairs
  • 43022: ZipArchive.Entries is not updated when ZipArchiveEntry is deleted
  • 43032: System.Uri cannot parse url with underscore at start
  • 43099: [watchOS] Cannot enter GC safe region if the thread is not attached
  • 43193: Keep CurrentCulture in async/await
  • 43265: Inconsistency in Compilation of Async Code Compared to MSFT Compilers
  • 43291: Runtime crash at reflection.c:monocustomattrsconstructby_type while calling GetCustomAttributes for a proxy class
  • 43320: Thread aborts in the middle of .cctor and hell break loose
  • 43357: WCSessionReplyHandler crashes WatchKit app
  • 43400: "using static" dependent on compile order
  • 43410: Nested exception trying to figure out what went wrong
  • 43471: pragma warning disable still shows warnings in "Errors" pad
  • 43512: TimeZoneInfo.ConvertTimeBySystemTimeZoneId ArgumentException
  • 43636: [Cycle 8] "Index was out of range. Must be non-negative and less than the size of the collection" in System.Collections.Generic.List1[T].set_Item()` when attempting to compile certain C# code involving tasks, async/await, and try/catch/finally
  • 43645: Items and properties not emitted for up to date targets
  • 43695: Nuget resolves .netstandard <= 1.3 when Xamarin.IOS does not support it
  • 43696: Delegate caching can invoke unrelated implementation leading to strange results
  • 43718: mcs crashes when unable to resolve type inside lambda using the 'as' operator
  • 43786: peverify is broken again
  • 43921: System.Threading.ThreadHelper.ThreadStart_Context tries to allocate, crashes
  • 44025: FTP download issue with IPv6
  • 44109: NetworkCredential does not convert SecureString
  • 44132: Thread.Sleep () overhead too big
  • 44164: gosharp-regexp benchmark triggers unwinding crash when profiling
  • 44168: Can use non-accessible member with nameof
  • 44296: Multicast not working on Android 7.0 devices
  • 44341: No way of updating async method local variables
  • 44381: Debugger crash with domain unloading and VSTU
  • 44402: Array doesn't implement non-generic IEnumerable
  • 44406: Xamarin.Mac.Socket exception:An address incompatible with the requested protocol was used
  • 44413: HttpHeaders.TryAddWithoutValidation behaves differently from .NET
  • 44440: Attempting to JIT error in function with pointer arithmetic
  • 44549: Ide Shuts down: System.ArgumentException: Item has already been added. Key in dictionary: 'XamlG' Key being added: 'XamlG'
  • 44552: Domain end unload event arrives before start unload event
  • 44624: Connecting to SQL Server using IPv4 exception.
  • 44707: RemotingConfiguration.Configure() Throws RemotingException Because it Cannot Load 'machine.config'
  • 44714: xbuild fails to find VB.NET compiler
  • 44729: Type.GetType("blah",true,false) throws TypeLoadException without message
  • 44751: Incorrect code flow analysis with goto and out parameter causes CS0177
  • 44843: SqlCommand.ExecuteReaderAsync throws NotImplementedException
  • 44918: "Assertion mini-arm.c:434, condition `lmfaddrtls_offset != -1' not met" prevent mono to run on ARM
  • 44937: System.Diagnostics.StartProcess does not detect dotnetcore compiled assemblies as managed
  • 44978: HttpClientHandler.SendAsync should throw HttpRequestException for proxy auth failure
  • 44994: DeflateStream decompression is incomplete if reading byte-by-byte
  • 45108: Proxy credentials not used for https url
  • 45137: Seeing new AAPT0000 errors when building certain projects against master
  • 45129: Uri.IsWellFormedUriString returns incorrect result for relative uris beginning with slash
  • 45131: Array of double*[] being treated as non-blittable when marshaled
  • 45286: C# string interpolation line does not compile on OSX but does on MSBuild
  • 45371: SIGSEGV occurs when making call from native to managed code
  • 45761: After network reconnected, web request fails for a couple of minutes with a NameResolutionFailure
  • 45774: Wrong scopes in .mdb in case of foreach loop
  • 45788: Marshaling a native NULL pointer to a managed array creates a new zero sized array
  • 45994: TLS connections on non-standard ports result in incorrect Server Name Indication value
  • 46175: If the RSA will be used by multiple threads, it has a variety of exceptions.
  • 46190: Overload resolution fails in a case where methods use a named parameter in different positions
  • 46250: Type.GetType with throwOnError true doesn't throw for a generic instance type with too few generic arguments
  • 46602: MobileAuthenticatedStream.AuthenticateAsServer() via EndPointListener
  • 46712: btls fails to build with gcc is v4.4.7 or earlier as they lack alignof/alignas
  • 47205: Uri.TryCreate throws exception
  • 47353: Mono.CSharp.MetadataImporter.set_IgnoreCompilerGeneratedField not found when running Cake on Mono 4.8
  • 48016: System.Net.NetworkInformation.DnsAddresses is always empty. Fix included.
  • 48516: ZipArchive.Save attempts to set position and seek non-seekable streams
  • 49056: Assertion at /Users/builder/data/lanes/3969/44931ae8/source/xamarin-macios/external/mono/mono/mini/mini-generic-sharing.c:2351, condition `info' not met
  • 49686: System.NotImplementedException at System.Reflection.Emit.DynamicMethod.GetCustomAttributes (System.Type attributeType, Boolean inherit)
  • 50242: Cannot use MSXSL format-date/format-time XPath extension functions on non-Windows platforms
  • 51562: NullReferenceException in BTLS X509CertificateImplBtls.Import()
  • 51805: [iOS]error MT6002: Could not strip assembly System.Net.Http.Primitives.dll while building ToDoAzure with Release|iPhone

API Changes

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.