Skip to content

Xamarin.Android 9.2.0.1

Compare
Choose a tag to compare

Xamarin.Android 9.2.0.1 was released as part of Visual Studio 2019 RC and Visual Studio 2019 Preview 4.

Issues Fixed

Application and Library Build Process

  • Developer Community 437807, GitHub 2685: Starting in the earlier Visual Studio 2019 Previews, builds could fail with "error MSB6006: "java.exe" exited with code 1." if project paths contained non-ASCII characters.

  • GitHub 2652: Starting in the earlier Visual Studio 2019 Previews, projects with AOT enabled would fail to build with "error XA5101: Missing Android NDK toolchains directory" unless the project also explicitly set the NDK path via the $(AndroidNdkDirectory) MSBuild property. Now the build will automatically locate the NDK if it is present in the ndk-bundle subdirectory of the Android SDK directory.

  • GitHub 2692: The build tasks and targets did not yet provide a warning for projects that have the minimum Android version set lower than Android 2.3 (API level 9). This warning is needed because the native parts of Xamarin.Android are built against Android NDK r14, so Xamarin.Android apps might not work correctly on devices running Android versions older than Android 2.3 (API level 9).

  • GitHub 2708: Starting in the earlier Visual Studio 2019 Previews, projects that used either Bundle assemblies into native code or AOT Compilation (Experimental) and did not explicitly set the NDK path via the $(AndroidNdkDirectory) MSBuild property would fail to build with two different error messages, neither of which mentioned how to resolve the error. Both scenarios now produce the same error, and the error mentions how to resolve the error by installing the NDK or setting the MSBuild property.

  • GitHub PR 2724: Starting in Visual Studio 2019 Preview 3, apps could encounter exceptions if they used AppDomain.GetAssemblies(). Xamarin.Forms apps that used CSS style sheets and did not have XAML Compilation enabled were one example. In Xamarin.Android 9.2.0.1, these apps will once again automatically preload all assemblies during startup, preventing the exceptions. Note that preloading the assemblies does increase startup time. Future versions of Xamarin.Forms will no longer require the preload step for any scenarios. If your app is already compatible with skipping the preload step, you can re-enable the performance improvement by setting the $(AndroidEnablePreloadAssemblies) MSBuild property to false in your .csproj file:

    <PropertyGroup>
        <AndroidEnablePreloadAssemblies>false</AndroidEnablePreloadAssemblies>
    </PropertyGroup>

Application Mono Framework Behavior on Device and Emulator

This version of Xamarin.Android updates the Mono 5.18 runtime and class libraries from Commit 725ba2a2 to Commit 163f45d8, adding 10 new commits.

A few improvements and issues fixed relevant to Xamarin.Android are:

  • GitHub PR 12058: Disable probing the AOT cache on Android, where it is unnecessary. This saves time during application startup.
  • GitHub 12538: Applications could sometimes hit an exception during startup due to a race condition.
  • GitHub 12688: StackTrace.GetFrames() was returning redundant additional frames for async methods.

Known Issues

  • GitHub 2679: Attempting to call new X509Certificate(bytes) can fail with "System.PlatformNotSupportedException: Cannot get `ISystemDependencyProvider`." on device or emulator. This issue depends on the order of type instantiations and method calls.

    Workaround: Invoke the non-public Mono.SystemDependencyProvider.Initialize() method at some point in your app before the first use of X509Certificate. One option is to use reflection to locate and invoke the method:

    var t = Type.GetType("Mono.SystemDependencyProvider, System", throwOnError: true);
    var m = t.GetMethod("Initialize", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static);
    m.Invoke(null, null);

    Another approach is to use some part of the public API surface that invokes the method behind the scenes. For example, the following line is sufficient:

    new X509Certificate2(new X509Certificate());