Xamarin.Android 11.2 release notes

| GitHub | Developer Community | System requirements | Blogs |

Installing

What's new in Xamarin.Android 11.2

Xamarin.Android 11.2 releases

Corresponding Visual Studio 2019 Preview release notes

March 2, 2021 — Xamarin.Android 11.2.0.21

This version is included in Visual Studio 2019 version 16.9 and Visual Studio 2019 for Mac version 8.9.

In Xamarin.Android 11.2.0.21

Rewritten fast deployment system

The Fast Deployment system has been fully rewritten to improve reliability and performance.

The new system also no longer uses the external drive for the fast deployment files. All of the files and tooling are now stored in the application's internal directory. This has an advantage in that when the application is uninstalled, all of the files and the tooling will be removed as well.

The new system will not work on any devices older than Android 5.0 Lollipop (API level 21), as it relies on features that only work Android 5.0 and later.

To debug an app running Android older than Android 5.0, disable Fast Deployment by setting the $(EmbedAssembliesIntoApk) property to False.

See the Fast Deployment documentation for more details.

Known Issue: Fast Deployment and .mdb files

The new Fast Deployment mechanism may fail with:

error : Could not find file "…/<somefile>dll.mdb"

See also: https://github.com/xamarin/xamarin-android/issues/5631

The issue here is that we are trying to fast deploy a file that does not exist. This is normally only caused when referencing an old NuGet package or Project which is still using the old Pdb format for debug symbols. This old format has to be converted into the Mdb format in order for those debug symbols to be used by the runtime. The new Portable Pdb format is fully supported.

The work around is to upgrade the nuget package to a newer version which is hopefully now using the Portable format. If it is for a Project reference you manage, then try changing the DebugType to be portable.

If none of that is an option, you can try adding the following to your application csproj.

<Target Name="_RemoveMdbFiles" BeforeTargets="_Upload">
    <ItemGroup>
        <_ResolvedSymbols Remove="**/*.dll.mdb" />
    </ItemGroup>
</Target>

Application and library build and deployment

  • Developer Community 1036602, GitHub Issue 5009: Starting in Xamarin.Android 10.2, .pdb files were not included in the APK if the managed linker was enabled.

  • Developer Community 1184573: Xamarin Android falsely saying that Resource does not exist in the current context (CS0103). Duplicate attr elements in declare-styleable styles were causing the design-time build system to crash. As a result the Resource.designer.cs was not being updated.

  • GitHub 2745: The @(JavaDocJar) build action would either cause an MSB3375 error, or wasn't used at all.

  • GitHub PR 4614: Syntax errors in AndroidManifest.xml always referred to the generated version of the file (like obj\Debug\90\android\manifest\AndroidManifest.xml), even when the syntax error was also present in the hand-written input Properties\AndroidManifest.xml file. Manifest errors are now fixed up to point to the Properties\AndroidManifest.xml file. An additional note will be added to the message to inform the user that the issue might not be in that file, but might be caused by code.

  • GitHub PR 4783: error XA1011: Using ProGuard with the D8 DEX compiler is no longer supported... AndroidLinkTool ... could appear without clues about the responsible MSBuild property in certain cases where AndroidLinkTool was empty. Xamarin.Android now provides additional XA1027 and XA1028 build warnings to indicate cases where one of the older EnableProguard or AndroidEnableProguard MSBuild properties is involved.

  • GitHub PR 4846: Starting in [Android 11][0], for Fast Deployment to work on an API 30 device or emulator, the following <queries/> entries must be present in AndroidManifest.xml:

    <?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.xamarin.android.helloworld">
      <uses-sdk android:targetSdkVersion="30" />
      <!-- ... -->
      <queries>
        <package android:name="Mono.Android.DebugRuntime" />
        <package android:name="Mono.Android.Platform.ApiLevel_30" />
      </queries>
    </manifest>
    

    These will be generated if $(AndroidUseSharedRuntime) is true and android:targetSdkVersion is 30 or higher.

  • GitHub PR 4966: An XA1025 error will now be emitted when $(AndroidAotMode) is Hybrid and one of the targeted ABIs is armeabi-v7a:

    error XA1025: The experimental 'Hybrid' value for the 'AndroidAotMode' MSBuild
    property is not currently compatible with the armeabi-v7a target ABI. To
    continue using the experimental 'Hybrid' value for 'AndroidAotMode', deselect
    the armeabi-v7a target ABI in the Visual Studio project property pages or edit
    the project file in a text editor and remove 'armeabi-v7a' from the
    'AndroidSupportedAbis' MSBuild property.
    

    Projects using the experimental Hybrid value for the AndroidAotMode MSBuild property that also include the value armeabi-v7a in the AndroidSupportedAbis MSBuild property will now see this build error to help indicate that applications built with these settings would abort during startup on armeabi-v7a ABI device environments (GitHub Issue 1218).

    If armeabi-v7a device compatibility is required for the app, the AndroidAotMode MSBuild property should be set to Normal or removed from the project file completely. To adjust the value of the AndroidAotMode MSBuild property, edit the project file in a text editor.

    If armeabi-v7a device compatibility is not required for the app, then deselect the armeabi-v7a target ABI in the Visual Studio project property pages to resolve the build error.

    In Visual Studio, the target ABIs can be adjusted under Supported architectures in the Advanced section of the Android Options tab of the project property pages

    In Visual Studio for Mac, the target ABIs can be adjusted under Supported ABIs in the Advanced tab of the Android Build section of the project property pages.

    Alternatively, edit the project file in a text editor and remove armeabi-v7a from the AndroidSupportedAbis MSBuild property by hand.

  • GitHub PR 5188: Improve performance by lazily loading an Android resource mapping file that is only used for error messages. This reduced the overall build time by 348 milliseconds in a real-world project in an initial clean build or incremental builds with Android resource changes.

  • GitHub Issue 4996: application deploy on Android 11 emulator fails with Mono.AndroidTools.AdbException: secure_mkdirs failed: Permission denied

  • GitHub Issue 4977: Update warning XA0113 to mention that Google Play now requires API-29, not API-28.

  • Github PR 5107: Starting in Xamarin.Android 11.0, building solutions in parallel with msbuild YourSolution.sln -m could fail with errors such as:

    obj\Release\100\android\manifest\AndroidManifest.xml(7,0): error APT2260: resource mipmap/ic_launcher (aka com.companyname.skiasharpsample:mipmap/ic_launcher) not found.
    obj\Release\100\android\manifest\AndroidManifest.xml(7,0): error APT2260: resource string/app_name (aka com.companyname.skiasharpsample:string/app_name) not found.
    obj\Release\100\android\manifest\AndroidManifest.xml(7,0): error APT2260: resource mipmap/ic_launcher_round (aka com.companyname.skiasharpsample:mipmap/ic_launcher_round) not found.
    obj\Release\100\android\manifest\AndroidManifest.xml(9,0): error APT2260: resource style/MainTheme.Splash (aka com.companyname.skiasharpsample:style/MainTheme.Splash) not found.
    Xamarin.Android.Aapt2.targets(226,3): error APT2067: failed processing manifest.
    
  • GitHub Issue 5218: System.IO.DirectoryNotFoundException could occur when building a project on a Windows network share.

  • GitHub Issue 5234: error XA0032: Java SDK 11.0 or above is required when using Android SDK Build-Tools 30.x.x. appeared unnecessarily when building on a system with Android SDK Build-Tools version 30 or higher installed.

  • GitHub PR 5266: Minor improvements to the way zip archives are created. Do not create folders in the classes.zip file and allow the auto flushing of a zip file to be switched off.

  • GitHub PR 5283: Fixed an issue where changing the selected device or emulator in the IDE would cause many parts of the build to run on an incremental build. This reduced the overall build time from 5.526 seconds to 1.451 seconds for this scenario in a small test project.

  • GitHub PR 5278: Update the linker in Release builds to insert GC.KeepAlive() invocations within JNI marshal methods to prevent premature instance collection. See also.

  • GitHub PR 5304: Add support for producing a proguard mapping.txt file to the build system. This file can be used by users to remove this warning "This App Bundle contains Java/Kotlin code, which might be obfuscated." when uploading packages to the Google Play Store. In order to opt-in to this behavior, set the $(AndroidProguardMappingFile) property in your project file to the path of the file you want generated:

    <PropertyGroup>
      <AndroidProguardMappingFile>$(OutputPath)\mapping.txt</AndroidProguardMappingFile>
    </PropertyGroup>
    
  • GitHub PR 5311: Add support for deploying and debugging against different user accounts on Android Devices. In order to use this you need to specify the AndroidDeviceUserId in either your csproj or on the command line.

      <PropertyGroup>
        <AndroidDeviceUserId>10</AndroidDeviceUserId>
      </PropertyGroup>
    
    msbuild foo.csproj /t:Install /p:AndroidDeviceUserId=10
    

    The value is the uid value you get from the following adb command

    adb shell pm list users
    

    This will return the following data

    Users:
      UserInfo{0:Owner:c13} running
      UserInfo{10:Guest:404}
    

    The uid is the first integer value. In the example they are 0 and 10.

  • GitHub PR 5351: The XA0113 warning has been updated to reflect a more recent minimum target version of Android 10 (API level 29) for submissions to the Google Play store. The following warning will now appear for projects that have an earlier version set under Compile using Android version: (Target Framework) in the Visual Studio project property pages:

    warning XA0113: Google Play requires that new applications and updates must use a TargetFrameworkVersion of v10.0 (API level  29) or above. You are currently targeting v9.0 (API level 28).
    
  • GitHub Issue 5357: Add support for the @(AndroidLibrary) build action.

  • GitHub PR 5375: Removed decoration of System.ComponentModel.CategoryAttribute to improve linker behavior. This reduced the .NET assembly size of a .NET 6 application by 3,271 bytes.

    CategoryAttribute was removed from properties on types such as Android.App.ActivityAttribute:

    -[Category ("@drawable;@mipmap")]
    public string? Icon { get; set; }
    -[Category ("@string")]
    public string? Label { get; set; }
    

    A full list of types changed:

    • Android.App.ActivityAttribute
    • Android.App.ApplicationAttribute
    • Android.App.InstrumentationAttribute
    • Android.App.ServiceAttribute
    • Android.Content.BroadcastReceiverAttribute
    • Android.Content.ContentProviderAttribute
  • GitHub PR 5410: Bump The version of the D8 dexer and R8 shrinker to 2.1.75.

  • GitHub PR 5411: The version of the bundletool executable included in Xamarin.Android has been updated from 1.2.0 to 1.4.0, bringing in several improvements and bug fixes.

  • GitHub PR 5477: error MSB3375: The file __AndroidLibraryProjects__.zip does not exist. could occur when building certain Xamarin.Android class library projects.

Binding fixes in Mono.Android.dll

Binding project build

  • GitHub PR 698: [generator] Emit [EditorBrowsable(false)] and [DebuggerBrowsable(false)] for JLO machinery.

  • GitHub PR 701: [generator] Add 'managedOverride' metadata to allow user to force 'override'/'virtual'.

  • GitHub PR 715: [generator] Provide line/col numbers for api.xml warnings.

  • GitHub PR 726: [generator] Prevent generating duplicate EventArgs classes.

  • GitHub PR 729: [generator] Fix invalid parsing of complex generic types.

  • GitHub PR 745: [jcw-gen] Do not register static methods on an interface.

  • GitHub PR 756: [ApiXmlAdjuster] Use different data model structures for better performance

  • GitHub PR 759: [class-parse] Support AndroidX's NonNull annotation.

  • GitHub PR 765: [generator] Fix MSBuild warning/error format for VS.

  • GitHub PR 768: [Java.Interop] Prevent premature collection w/ JniInstance*

  • GitHub PR 770: [generator] Ensure DIM from Cecil imported references get correctly marked.

  • GitHub PR 5431: [Xamarin.Android.Build.Tasks] Enable NRT for bindings projects.

    Adding <Nullable>enable</Nullable> to an Android Bindings project that has <LangVersion> of at least C# 8 will cause the generated code to include nullable reference types. Many Nullable annotations from the Java/Android ecosystem are supported. (Supported List)

Better file association for Android manifest syntax errors

Syntax errors in AndroidManifest.xml previously always referred to the generated version of the file (like obj\Debug\90\android\manifest\AndroidManifest.xml), even for syntax errors that were also present in the manually configured input Properties\AndroidManifest.xml file. Android manifest errors are now fixed up to point to the Properties\AndroidManifest.xml file. The errors also now include a note to inform users that manifest generation attributes in source code files can be responsible for the errors in some cases.

Deprecation of AAPT in favor of AAPT2

warning XA1026: Using AAPT is deprecated in favor of AAPT2. Please enable 'Use incremental Android packaging system (aapt2)' in the Visual Studio project property pages or edit the project file in a text editor and set the 'AndroidUseAapt2' MSBuild property to 'true'.

Google has deprecated the AAPT command-line tool in favor of AAPT2 going forward. Xamarin.Android has accordingly now deprecated <AndroidUseAapt2>false</AndroidUseAapt2> as well.

Update the AndroidUseAapt2 MSBuild property to true to select AAPT2. This property corresponds to the Use incremental Android packaging system (aapt2) setting in the Visual Studio project properties pages. Alternatively, remove <AndroidUseAapt2> from the .csproj file to let the build select the default value true.

Important

AAPT2 will in some cases enforce stricter rules on resource files than the previous AAPT, so some adjustments might be needed if you see new error messages that come from AAPT2 itself rather than from the Xamarin.Android build tasks.

If needed, the --legacy switch can run AAPT2 in an AAPT compatibility mode. Add the following to your .csproj file:

<PropertyGroup>
  <AndroidAapt2CompileExtraArgs>--legacy</AndroidAapt2CompileExtraArgs>
</PropertyGroup>

Deprecation of DebugType full and pdbonly

Support for .mdb or .pdb symbols files that were built with the DebugType MSBuild property set to full or pdbonly is now deprecated. This applies to .mdb and .pdb files in application projects as well as in referenced libraries, including NuGet packages.

warning XA0125: 'AndroidApp1.pdb' is using a deprecated debug
information level. Set the debugging information to Portable in the
Visual Studio project property pages or edit the project file in a
text editor and set the 'DebugType' MSBuild property to 'portable' to
use the newer, cross-platform debug information level. If this file
comes from a NuGet package, update to a newer version of the NuGet
package or notify the library author.

Set DebugType to portable in the application project as well all library references. portable is the recommended setting for all projects from now on. The older full and pdbonly settings are for older Windows-specific file formats. .NET 6 and higher will not support those older formats.

In Visual Studio, go to Properties > Build > Advanced in the project property pages and change Debugging information to Portable.

In Visual Studio for Mac, go to Build > Compiler > Debug information in the project property pages and change Debug information to Portable.

If the problematic symbol file comes from a NuGet package, update to a newer version of the package or notify the library author.

Deprecation of JavaDocJar Build action

The @(JavaDocJar) Build action build action is deprecated, and will not be supported in .NET 6. Please use the @(JavaSourceJar) Build action.

Removal of ${library.imports:} support in AndroidResgenExtraArgs MSBuild property

A text templating feature for AAPT and AAPT2 has been removed that provided a workaround for the Amazon Fire Phone:

<AndroidResgenExtraArgs>-I ${library.imports:eac-api.jar} -I ${library.imports:euclid-api.jar}</AndroidResgenExtraArgs>

The ${library.imports:...} syntax should no longer be needed by modern Android libraries. .aar files are the recommended way for Java/Kotlin libraries to distribute Android resources to be consumed by Xamarin.Android application projects.

Note that the AndroidResgenExtraArgs and AndroidAapt2LinkExtraArgs MSBuild properties will continue to pass additional arguments to aapt and aapt2 link with the ${library.imports:...} syntax removed.

UseShortFileNames=false is no longer supported

In previous versions of Xamarin.Android, you could set the UseShortFileNames MSbuild property in your .csproj file:

<PropertyGroup>
  <UseShortFileNames>false</UseShortFileNames>
</PropertyGroup>

This would tell Xamarin.Android's MSBuild targets to use the "long" folder names such as:

  • obj\Debug\lp -> __library_projects__
  • obj\Debug\lp*\jl -> library_project_imports
  • obj\Debug\lp*\nl -> native_library_imports

This was useful when UseShortFileNames was a new feature, giving developers a way to "opt out" if they hit a bug. However, UseShortFileNames has defaulted to true since around July 2017 to help with the Windows API maximum path length limitation.

This functionality has been removed from Xamarin.Android. Short file names will be used going forward.

All enhancements and issues fixed in Xamarin.Android 11.2

GitHub enhancements

GitHub bugs

Developer Community

Other changes in Xamarin.Android 11.2

Other changes

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.2 is based on the open-source Xamarin.Android repositories: