Skip to content

Releases: dotnet/android

Xamarin.Android 9.1.8.0

14 Feb 05:04
Compare
Choose a tag to compare

Xamarin.Android 9.1.8.0 was released to the Visual Studio 2017 for Mac version 7.7 updater channels.

This version of Xamarin.Android updates the Mono 5.14 runtime and class libraries from Commit 62031dca to Commit b5381878, adding 2 new commits. This aligns Xamarin.Android to the Mono commit used by the matching releases of Xamarin.iOS and Xamarin.Mac.

Xamarin.Android 9.1.7.0

12 Feb 20:29
Compare
Choose a tag to compare

Xamarin.Android 9.1.7.0 was released as part of Visual Studio 2017 version 15.9.7.

Issues Fixed

  • Developer Community 379758, Mono Framework GitHub 10488: HttpWebRequest was sometimes leaving exceptions unobserved in its internal Task objects, resulting in uncatchable exceptions that in turn caused noisy invocations of any event handlers subscribed to the TaskScheduler.UnobservedTaskException event.

Xamarin.Android 9.1.103.12

13 Feb 22:14
Compare
Choose a tag to compare
Pre-release

Xamarin.Android 9.1.103.12 was released as part of Visual Studio 2019 Preview 3.

What's New

Temporary Breakage for Apps That Use AppDomain.GetAssemblies(), Including Xamarin.Forms Apps with CSS

Due to an application startup performance improvement that stops preloading all assemblies during startup, the behavior of AppDomain.GetAssemblies() has changed in this preview. This will become an opt-in behavior in the next Xamarin.Android 9.2 preview, but in Xamarin.Android 9.1.103.12, there is not yet a way to prevent the new behavior, so this change will disrupt applications that rely on the old behavior.

C# code using System.Reflection and AppDomain.GetAssemblies() may be affected such as:

  • Dependency injection libraries
  • Certain Xamarin.Forms features
  • Potentially other mobile frameworks (MVVM, etc.) that leverage System.Reflection

A workaround to explicitly call Assembly.Load() at startup may be needed.

Xamarin.Forms apps that use CSS style sheets are one important scenario affected by this change:

  • Xamarin.Forms GitHub 5164: Xamarin.Forms apps that use CSS style sheets and do not have XAML Compilation enabled fail with a NullReferenceException at Xamarin.Forms.Xaml.ApplyPropertiesVisitor.ProvideValue() during application startup on device or emulator.

    Temporary workaround: Add a call to System.Reflection.Assembly.Load("Xamarin.Forms.Xaml") as the first statement in the Activity.OnCreate(Bundle bundle) override in the Android app project:

    // In your MainActivity.cs, or first activity
    protected override void OnCreate(Bundle bundle)
    {
        // Workaround, to manually load Xamarin.Forms.Xaml before Xamarin.Forms startup
        Assembly.Load("Xamarin.Forms.Xaml");
    
        base.OnCreate(bundle);
    
        global::Xamarin.Forms.Forms.Init(this, bundle);
        LoadApplication(new App());
    }

    This workaround will no longer be necessary in the next Xamarin.Android 9.2 preview version.

App Startup Performance Improvements

GitHub PR 2515: Optimize several application startup operations:

  • Reduce Java class lookup.
  • Don't lookup android.os.Build.VERSION.SDK_INT via JNI.
  • jstring handling improvements.
  • Review logging messages.
  • Improve package name hash generation.
  • Improve environment variable processing.
  • Stop preloading all assemblies.
  • Avoid using "system properties" to control Mono features.
  • Desktop version is now a compile-time build option, not runtime.
  • Initialize xamarin_getifaddrs() on-demand, not at startup.

These optimizations reduced the average startup time for a test application from 0.7 seconds to 0.3 seconds in the Release configuration and from 1.4 seconds to 1.1 seconds in the Debug configuration.

Mono.Data.Sqlite SQLite Version Update to 3.26.0

The version of SQLite used by Mono.Data.Sqlite in Xamarin.Android has been updated to 3.26.0, bringing in additional improvements and bug fixes compared to the Xamarin.Android 9.2 preview.

Incompatibility with Minimum Android Versions below Android 2.3 (API level 9)

Xamarin.Android projects configured to use a minimum Android version below Android 2.3 (API level 9) will fail to build with the following error:

error: method init in class Runtime cannot be applied to given types;
				Runtime.init (
  required: String,String[],String,String[],ClassLoader,String[],String[],String,int,String[]
  found: String,String[],String,String[],ClassLoader,String[],String[],String
  reason: actual and formal argument lists differ in length

The recommended way to resolve this error is to update the minimum API level to Android 2.3 (API level 9) or higher. This value can be found in the project properties under Android Manifest > Minimum Android version in Visual Studio and under Android Application > Minimum Android version in Visual Studio for Mac.

The error appears because the app startup performance improvements in this release expose an obsolete code path for these older API levels.

Issues Fixed

Application and Library Build Process

Application Behavior on Device and Emulator

  • GitHub 1673: Attempting to run large APKs on device or emulator could fail on startup if the size of the APK exceeded the largest available contiguous block of free memory. In Xamarin.Android 9.2, the app startup process now calls mmap() separately for individual files from the APK instead of once for the whole APK. This allows larger APKs to run successfully.
  • GitHub 2081: Applications with the android:directBootAware attribute set to true for the whole application or for an activity, content provider, broadcast receiver, or service would quit unexpectedly when attempting to launch on a freshly rebooted, locked device running Android 7.0 Nougat or higher.

Application Mono Framework Behavior on Device and Emulator

This version of Xamarin.Android updates the Mono 5.18 runtime and class libraries from Commit 23f2024a to Commit 725ba2a2, adding 29 new commits.

A couple changes relevant to Xamarin.Android are:

  • GitHub PR 11828: Fix race condition in XmlCharType.Instance
  • GitHub PR 12410: Fix debugger crash when there is a generic struct with a field that is an enumerator

Design-Time Build Process

  • GitHub 2548: In Visual Studio 2019 Preview 2, the _ResolveAssemblies build target could fail during design-time builds triggered by the Android designer, leading to errors in the Android designer.
  • GitHub PR 2607: In Visual Studio 2019 Preview 2, the ResolveLibraryProjectImports task was not always returning full paths for the output items. This could cause errors when working with the Android designer.

Xamarin.Android 9.1.103.7

23 Jan 21:21
Compare
Choose a tag to compare
Pre-release

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][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][7-0-fast-deployment], note that this new version solves the [incompatibility with cus...

Read more

Xamarin.Android 9.1.5.1

19 Jan 00:48
2cc615a
Compare
Choose a tag to compare

Xamarin.Android 9.1.5.0 was released as part of Visual Studio 2017 for Mac version 7.7.3.

Issues Fixed

  • The Xamarin.Android installer package for macOS caused a dialog "To use the
    'java' command-line tool you need to install a JDK." to appear after
    installation if the Microsoft Mobile OpenJDK Distribution was the
    only installed JDK.

Xamarin.Android 9.1.5.0

08 Jan 19:59
2cc615a
Compare
Choose a tag to compare

Xamarin.Android 9.1.5.0 was released as part of Visual Studio 2017 version 15.9.5.

Issues Fixed

  • GitHub 2257: Apps that referenced hundreds of assemblies would quit unexpectedly during startup because they consumed too many JNI local references: "JNI ERROR (app bug): local reference table overflow (max=512)". The local references are now released more aggressively, allowing this kind of app to run successfully.
  • GitHub 2408: The @(AndroidAarLibrary) Build Action could lead to errors about missing resources during incremental builds. This particular cause of errors about missing resources should not have affected many users yet because the @(AndroidAarLibrary) build action is primarily intended for future use in Android library bindings NuGet packages published by the Xamarin team.

Xamarin.Android 9.1.4.2

12 Dec 18:51
Compare
Choose a tag to compare

Xamarin.Android 9.1.4.2 was released as part of Visual Studio 2017 version 15.9.4 and Visual Studio 2017 for Mac version 7.7.

See the release notes for additional details.

Xamarin.Android 9.1.0.37

24 Oct 19:41
Compare
Choose a tag to compare
Pre-release

Xamarin.Android 9.1.0.37 was released as part of Visual Studio 15.9 Preview 4.

Xamarin.Android 9.1.101.6

06 Dec 22:57
Compare
Choose a tag to compare
Pre-release

Xamarin.Android 9.1.101.6 was released as part of Visual Studio 2019 Preview 1 and Visual Studio 2019 for Mac Preview 1.

Xamarin.Android 9.0.0.0.

03 Jul 19:43
Compare
Choose a tag to compare
Pre-release

Xamarin.Android 9.0.0.0 was released as part of Visual Studio 15.8 Preview 4.