Partager via


Xamarin.Android 11.1 release notes

| GitHub | Developer Community | System requirements | Blogs |

Installing

What's new in Xamarin.Android 11.1

Xamarin.Android 11.1 releases

  • November 10, 2020 — Xamarin.Android 11.1.0.17 in Visual Studio 2019 version 16.8 and Visual Studio 2019 for Mac version 8.8

Corresponding Visual Studio 2019 release notes

November 10, 2020 — Xamarin.Android 11.1.0.17

This version is included in Visual Studio 2019 version 16.8 and Visual Studio 2019 for Mac version 8.8.

In Xamarin.Android 11.1.0.17

Deprecations, removals, and default configuration changes

Build and deployment performance

GitHub PR 4975: Cache the results of the FilterAssemblies MSBuild task in memory so they can be reused across different MSBuild targets during the build. This decreased incremental build times for the Xamarin.Forms source build from about 170 milliseconds to about 100 milliseconds on a test system. The savings will be bigger on larger solutions.

android:extractNativeLibs set to "true" by default

Starting in Xamarin.Android 11.0, projects that had references to the Xamarin.AndroidX NuGet packages or that were otherwise configured to use the improved manifest merging option would get a value of "false" by default for the android:extractNativeLibs Android manifest attribute due to changes in the latest version of the manifest merger tool from Google. Because this value had previously been "true" when left blank, this could cause unexpected behavior changes for Xamarin.Android applications. Xamarin.Android now sets this attribute to "true" by default even when using the improved manifest merging.

According to the Android documentation, extractNativeLibs affects APK size and install size:

Whether or not the package installer extracts native libraries from the APK to the filesystem. If set to false, then your native libraries must be page aligned and stored uncompressed in the APK. No code changes are required as the linker loads the libraries directly from the APK at runtime.

This is a tradeoff that each developer should decide upon on a per-application basis. Is a smaller install size at the cost of a larger download size preferred?

Xamarin.Android now emits android:extractNativeLibs="true" by default, preferring smaller APK sizes. You can get the opposite behavior with an AndroidManifest.xml such as:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
        android:versionCode="1" android:versionName="1.0" package="com.companyname.hello">
    <uses-sdk android:minSdkVersion="23" android:targetSdkVersion="30" />
    <application android:label="Hello" android:extractNativeLibs="false" />
</manifest>

Corrected garbage collection behavior for Android bindings and bindings projects

In previous Xamarin.Android versions, errors similar to JNI DETECTED ERROR IN APPLICATION: use of deleted global reference and JNI ERROR (app bug): attempt to use stale Global 0x2a2a (should be 0x2a26) could cause apps to abort under certain specific timing conditions where a managed garbage collection started just after a Java.Lang.Object subclass method call.

The Xamarin.Android bindings project build process now includes a fix for this issue.

The set of Android API bindings that are included directly as part of the Xamarin.Android SDK have been updated accordingly to include the fix.

Note

This fix will not solve the problem for other bindings libraries until the libraries are rebuilt using this new Xamarin.Android version. Bindings library authors are therefore encouraged to build and publish new versions of their libraries using this new Xamarin.Android version at their earliest convenience.

apksigner from Android SDK Build-Tools 30.0.3 now included

Xamarin.Android now packages its own copy of the apksigner executable. The current included version is aligned with Android SDK Build-Tools 30.0.3.

Attempting to use the upstream apksigner that's packaged in Android SDK Build-Tools 30.0 from the Android SDK Manager with Java JDK 8 results in the following error, as mentioned in the Xamarin.Android 11.0 release notes:

java.lang.UnsupportedClassVersionError: com/android/apksigner/ApkSignerTool has been compiled by a more recent version of the Java Runtime (class file version 53.0), this version of the Java Runtime only recognizes class file versions up to 52.0

The new apksigner that is now included as part of Xamarin.Android matches the source version of the upstream tool but is built against Java JDK 8 so that Xamarin.Android can now use Android SDK Build-Tools 30.0 alongside Java JDK 8.

Default Android SDK Platform-Tools version update to 30.0

The default Android SDK Platform-Tools version has been updated from 29.0.5 to 30.0.4. This version can be changed per-project if needed via the AndroidSdkPlatformToolsVersion MSBuild property.

Note

Unlike the Platform-Tools, the default Android SDK Build-Tools version is still 29.0.2 in this release. Projects that attempt to override the AndroidSdkBuildToolsVersion MSBuild property to a 30.0.x version will currently fail to build with an error similar to:

error XA0032: Java SDK 11.0 or above is required when using Android SDK Build-Tools 30.0.0.

This error will be removed in a future version now that Xamarin.Android provides its own version of apksigner that is compatible with Java JDK 8. Relatedly, Android SDK Build-Tools version 30.0.2 and higher as provided by the Android SDK Manager are now also compatible with Java JDK 8.

Deprecation of Android Wear references in app projects

Referencing an Android Wear application project from an Android phone application project is now deprecated and will produce a build warning similar to:

warning XA4312: Referencing the Android Wear application project 'com.contoso.wearapp' from an Android application project is deprecated and will no longer be supported in a future version of Xamarin.Android. Remove the Android Wear application project reference from the Android application project and distribute the Wear application as a standalone application instead.

To resolve this warning, remove the reference to Android Wear project from the phone application project and distribute the Android Wear project as a standalone Wear application instead.

Soft deprecation of undocumented ProguardConfigFiles MSBuild property

Xamarin.Android's ProGuard compatibility feature included an undocumented ProguardConfigFiles MSBuild property that could be used as an alternative to the ProguardConfiguration Build Action. That ProguardConfigFiles property is now deprecated.

Any project authors who are currently using the ProguardConfigFiles MSBuild property are encouraged to update to the ProguardConfiguration Build Action instead.

For example, a .csproj file could contain a use of the ProguardConfiguration MSBuild property similar to the following:

<PropertyGroup>
  <ProguardConfigFiles>
    proguard1.cfg;
    proguard2.cfg;
  </ProguardConfigFiles>
</PropertyGroup>

To update a .csproj that contains a use of ProguardConfiguration like that, remove the ProguardConfiguration element from the .csproj file and instead set the proguard1.cfg and proguard2.cfg files to use the ProguardConfiguration Build Action. This adds the files as ProguardConfiguration items in the .csproj file:

<ItemGroup>
  <ProguardConfiguration Include="proguard1.cfg" />
  <ProguardConfiguration Include="proguard2.cfg" />
</ItemGroup>

Issues fixed and other small changes in Xamarin.Android 11.1.0.17

Application and library build and deployment

  • Developer Community 1086457: Changes to libraries referenced by the .NET Standard library in a standard Xamarin.Forms solution were not reflected in the running app without a clean rebuild. More generally, this issue affected any library referenced indirectly via a .NET Standard library that had the ProduceReferenceAssembly MSBuild property set to true.

  • Developer Community 1120933: XABLD7019: System.UnauthorizedAccessException: Access to the path ... .lz4 is denied prevented projects from building successfully in the Release configuration if the managed linker was disabled in that configuration.

  • Developer Community 1141659: Starting in Xamarin.Android 11.0, the Updating Resources... build step could get stuck indefinitely if .DS_Store or any file starting with . was included in the project with the AndroidResource Build Action.

  • Developer Community 1141659: Starting in Xamarin.Android 11.0, the Updating Resources... build step could get stuck indefinitely if a NuGet package containing an AndroidResource file name starting with . was included in a project.

  • Developer Community 1144021 and GitHub 4990: Starting in Xamarin.Android 11.0, ADB0010: [INSTALL_FAILED_INVALID_APK: Failed to extract native libraries, res=-2] build error could prevent apps from being deployed after AndroidManifest.xml changes.

  • Developer Community 1144910: Starting in Xamarin.Android 11.0, errors similar to error APT2260: resource mipmap/ic_launcher (aka com.companyname.skiasharpsample:mipmap/ic_launcher) not found and error CS0117: 'Resource' does not contain a definition for 'Layout' could prevent building projects when maximum number of parallel project builds was set higher than one in the Visual Studio options or when the -m switch was used in command line MSBuild builds.

  • Developer Community 1157593: Modifications to files set to use the AndroidAsset Build Action were not included as expected in incremental builds. Clean rebuilds were required to propagate the changes as expected.

  • Developer Community 1182026: Starting in Xamarin.Android 11.0, the Executing compile -o ... build step could get stuck indefinitely on certain systems where Environment.ProcessorCount returned 1.

  • GitHub 1597: Marshaling of java.util.Map instances in files set to use the AndroidInterfaceDescription Build Action was incorrect.

  • GitHub 4565: Errors or warnings similar to Missing class: com.android.tools.lint.detector.api.Detector could appear unexpectedly in the build output of apps that referenced custom Xamarin.Android bindings libraries for .aar files.

  • GitHub 4677: On Windows, running the InstallAndroidDependencies MSBuild target on the command line did not yet allow continuous build environments to install the Android SDK dependencies as expected.

  • GitHub 4818: Projects that had the undocumented AndroidAotMode MSBuild property set to the experimental Hybrid value did not strip away the IL from the resulting managed assemblies as expected.

  • GitHub PR 4824: No longer create NOTICE files in app packages.

  • GitHub PR 4829: No longer fast deploy Android resources for the Assemblies:Dexes fast deployment mode.

  • GitHub PR 4984: Avoid logging the full contents of item lists in diagnostic MSBuild logs in cases where MSBuild conditions only need to check if the item lists are empty or non-empty.

  • GitHub 4986: Updates to Android tooling (manifest-merger), caused //application/@android:extractNativeLibs to be set to "false" by default. This could cause an undesirable APK file size increase that was more noticeable for Xamarin.Android applications using AOT. Xamarin.Android now sets extractNativeLibs to "true" by default.

  • GitHub 4998: Files under lib/ must have .so extension, found 'lib/x86/gdbserver'. build error prevented building app bundles for projects with references to Android C++ library projects.

  • GitHub 5024: error XA0119: Using the shared runtime and Android App Bundles at the same time is not currently supported build error could mistakenly appear for Xamarin.Android class libraries when the AndroidPackageFormat MSBuild property was set to aab.

  • GitHub PR 5038: Errors similar to error APT2260: resource drawable/icon (aka com.contoso.androidapp:drawable/icon) not found could prevent building projects that were using ResizetizerNT and google-services.json together. The build system has now been updated to ensure each resource directory has its own unique cache file.

  • GitHub 5043: i686-linux-android-ld.EXE: error: cannot open ... Debug\monoandroid10.0\android\typemaps.x86.o: No such file or directory could prevent building projects located under paths that contained .s.

  • GitHub 5049: Starting in Visual Studio 2019 version 16.7, build errors similar to Feature 'XYZ' is not available in C# 7.3. Please use language version 8.0 or greater. could prevent projects from using C# 8.0 language features.

Application behavior on device and emulator

  • GitHub 4098: Exceptions similar to java.lang.ClassCastException: mono.android.runtime.JavaObject cannot be cast to float[] prevented passing certain C# types to some Android APIs.

  • GitHub 4632: UNHANDLED EXCEPTION was shown unexpectedly in the application output in certain cases for handled exceptions that had been propagated through both Java and managed code.

  • GitHub 4893: System.ArgumentNullException: Value cannot be null ... at Java.Interop.TypeManager.RegisterType (System.String java_class, System.Type t) could prevent launching apps on Android 9.0 Pie (API level 28) x86 emulators.

  • GitHub 4989: Calling this.Dispose() from within a Java.Lang.Object.Dispose(bool) override threw a System.ArgumentException.

Android API bindings

  • GitHub PR 5106: Bindings for overloads of Map.Of() that took more than fourteen parameters were not yet available.

Bindings projects

  • GitHub 4956: warning MSB6002: The command-line for the "BindingsGenerator" task is too long could prevent building bindings library projects, most commonly when they referenced Xamarin.AndroidX NuGet packages.

  • GitHub 5027: Syntax errors similar to ) expected could prevent building bindings projects after updating the Compile using Android version: (Target Framework) setting to Android 11 (R).

  • Java.Interop GitHub PR 672: For nested Java types that have protected visibility within sealed types, generate bindings that have private visibility to avoid C# warning CS0628.

  • Java.Interop GitHub 682: Ignorable warning BG8604: top ancestor ... not found for nested type ... appeared for public types nested under non-public types in Kotlin libraries. Those nested types are now skipped as expected.

  • Java.Interop GitHub 694: Kotlin synthetic constructors were not yet ignored, resulting in unactionable error messages such as:

    Error while processing '[Constructor] MaterialDialog(android.content.Context p0, com.afollestad.materialdialogs.DialogBehavior p1, int p2, kotlin.jvm.internal.DefaultConstructorMarker p3)' in '[Class] com.afollestad.materialdialogs.MaterialDialog': Type 'kotlin.jvm.internal.DefaultConstructorMarker' was not found.
    
  • Java.Interop GitHub 717: Error while processing type ... Type 'android.app.IntentService' was not found. prevented building bindings for libraries with classes that inherited from android.app.IntentService.

  • Java.Interop GitHub 719: Bindings did not yet use GC.KeepAlive() calls to ensure that method arguments would never be garbage collected before they were passed to Java.

Application publishing

  • GitHub 4949: The VtsVndkDependencyTest test from the Android Vendor Test Suite would not pass for Xamarin.Android apps installed into system ROMs by device vendors.

Application Mono Framework behavior on device and emulator

This version of Xamarin.Android updates the Mono 6.12 runtime and class libraries from Commit 83105ba2 to Commit be2226b5, adding 17 new commits.

Fixes included for issues reported with Xamarin.Android applications:

  • Mono GitHub 8806: DWARF debugging symbols were incorrect for projects configured to use AOT Compilation with Use LLVM Optimizing Compiler.

Thank you

A big Thank You! to community members who contributed improvements in this release:

Feedback welcome

Your feedback is important to us. If there are any problems with this release, check our GitHub Issues, Xamarin.Android Community Forums and Visual Studio Developer Community for existing issues. For new issues within the Xamarin.Android SDK, please report a GitHub Issue. For general Xamarin.Android experience issues, let us know via the Report a Problem option found in your favorite IDE under Help > Report a Problem.

Open source

Xamarin.Android 11.1 is based on the open-source Xamarin.Android repositories: