Xamarin.Android 11.0.0.3 Preview
Pre-releaseJuly 14, 2020 — Xamarin.Android 11.0.0.3 was published as part of Visual Studio 2019 version 16.7 Preview 4 and Visual Studio 2019 for Mac version 8.7 Preview 4.
Corresponding Visual Studio 2019 Preview release notes
In Xamarin.Android 11.0.0.3
- Bindings for Android 11 Beta
- Bindings projects enumeration enhancements
- Issues fixed
- Installing
- Open source
Deprecations, removals, and default configuration changes
- XA0119 error for incompatible use of Android App Bundle format in Debug configuration
- AAPT2 version update to 4.0.0
Bindings for Android 11 Beta
This version includes bindings for the Android 11 Beta from Google. See the Android 11 Beta documentation for additional information about the behavior and API changes in this new Android version. Because Android 11 Beta provides the finalized SDK and NDK APIs, the Xamarin.Android bindings are now also finalized and the Xamarin.Android SDK version number has been updated to 11.0. To use the bindings for the new APIs in a Xamarin.Android project, set Compile using Android version: (Target Framework) to Android 11 (R) under the Application tab of the Visual Studio project property pages. This sets the TargetFrameworkVersion
property to v11.0
in the .csproj file:
<TargetFrameworkVersion>v11.0</TargetFrameworkVersion>
Note: The default and recommended Android SDK Build-Tools version for Xamarin.Android is still 29 because Build-Tools version 30.0 currently requires Java JDK 9 or higher, while both Xamarin.Android and Android Studio still require JDK 8. Android SDK Build-Tools 29 is compatible with the Android 11 bindings, so it is recommended to continue using Android SDK Build-Tools 29 for now.
Attempting to use Android SDK Build-Tools 30.0 with Java JDK 8 results in the following error:
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
Project authors who wish to try Android SDK Build-Tools 30.0 can follow the steps under Preliminary Java JDK 11 compatibility to install and configure Java JDK 11.
Bindings projects enumeration enhancements
The Transforms\EnumFields.xml file in bindings projects now allows <mapping>
and <field>
elements that use just clr-enum-type
and clr-name
attributes, with no jni-interface
or jni-name
attributes. This provides additional flexibility to define custom C# enumerations that are visible to the bindings generation process and do not correspond to any Java type in the bound Java library. For example:
<mapping clr-enum-type='Contoso.Permissions' bitfield='true'>
<field clr-name='Read' value='0' />
<field clr-name='Write' value='1' />
<field clr-name='Execute' value='2' />
</mapping>
For enumerations that do correspond to Java types, project authors should continue to include the jni-interface
and jni-name
attributes as before.
XA0119 error for incompatible use of Android App Bundle format in Debug configuration
The Android App Bundle publishing format is not currently compatible with the recommended fast deployment settings for Debug configuration deployments. Previously, projects that had Android Package Format (AndroidPackageFormat
) set to aab in the Debug configuration that also had the recommended Use Shared [Mono] Runtime setting enabled would produce a build warning and then fail to launch on device.
Because this configuration is not currently supported, Xamarin.Android now produces an error for it instead of a warning:
error XA0119: Using the shared runtime and Android App Bundles at the same time is not currently supported. Use the shared runtime for Debug configurations and Android App Bundles for Release configurations.
To resolve this error, change the Android Package Format setting in the Visual Studio project property pages to apk for the Debug configuration. This corresponds to the apk
value for the AndroidPackageFormat
MSBuild property in the .csproj file:
<PropertyGroup>
<AndroidPackageFormat>apk</AndroidPackageFormat>
</PropertyGroup>
This error is only relevant for Debug configuration builds. Release configuration builds can continue to use the Android App Bundle packaging format.
AAPT2 version update to 4.0.0
The version of the Android Asset Packaging Tool AAPT2 included in Xamarin.Android has been updated from 3.5.3 to 4.0.0.
Issues fixed
Application behavior on device and emulator
- Developer Community 970610, Java.Interop GitHub 661: System.TypeLoadException: 'Could not load type 'Android.App.Application.IActivityLifecycleCallbacks' could cause apps using the Android 11 Developer Preview bindings to abort during startup.
- Developer Community 1045818: Starting in Xamarin.Android 10.3 on Windows, errors similar to Java.Lang.RuntimeException: 'Font asset not found Fonts/fontello.ttf' could cause apps to abort unexpectedly on device after they were updated and redeployed from Visual Studio on Windows.
- Developer Community 1050379, GitHub 4795: Starting in Xamarin.Android 10.3, Unable to activate instance of type Android.Util.SparseArray`1[E] could cause apps built in the Debug configuration to abort.
- GitHub 4772, GitHub 4852: System.DllNotFoundException: libmono-native.so assembly:<unknown assembly> type:<unknown type> member:(null) could cause apps to abort during startup on certain Android 5.0 Lollipop (API level 21) and Android 5.1 Lollipop (API level 22) devices.
- GitHub 4791: Starting in Xamarin.Android 10.3, many typemap: module matching MVID [...] not found. messages were logged to the application output for certain running apps, obscuring other logging statements of interest. These messages were diagnostic and did not indicate problems in the apps.
- GitHub PR 4792: Starting in Xamarin.Android 10.4.0.0, F/monodroid-assembly(11348): Compressed assembly 'mscorlib.dll' is larger than when the application was built (expected at most 146432, got 2043392). Assemblies don't grow just like that! could appear in application logs in certain cases for apps using the new default managed assembly compression. The problem described by the message could result in other unexpected behaviors in the running app.
- GitHub 4805: Starting in Xamarin.Android 10.3, localized resources from .resx files in Xamarin.Android application projects were no longer deployed when building and deploying from within Visual Studio to an attached device or emulator. (In contrast, clean builds started on the command line worked as expected.)
- GitHub 4809: Starting in Xamarin.Android 10.3, System.MemberAccessException: Cannot create an instance of ... could cause apps built in the Debug configuration to abort when attempting to use certain APIs involving types that have both generic and non-generic versions such as
Android.Widget.ArrayAdapter
. - GitHub PR 4846: On Android 11 (API level 30) devices and emulators, java.lang.RuntimeException: Unable to get provider mono.MonoRuntimeProvider: java.lang.RuntimeException: Unable to find application Mono.Android.Platform.ApiLevel_30! caused apps to abort during startup for projects with the Target Android version set to API level 30 in the Android Manifest tab of the project property pages.
Application and library build and deployment
- Developer Community 1061307 Changes to files set to use the LinkDescription Build Action were not included as expected in incremental builds. Clean rebuilds were required to propagate the changes as expected.
- Developer Community 1076396: DllImport error loading library '__Internal': 'Could not load library: Library '/system/lib64/libmonodroid.so' not found.' caused apps to abort during startup when built in an unsupported Debug configuration, with Android Package Format set to aab, because the build only provided a warning. The build now produces an error instead.
- GitHub 4790: Starting in Xamarin.Android 10.3, errors similar to error XA3006: Could not compile native assembly file: typemaps.x86.s caused incremental builds to fail after changes to the Supported architectures (
AndroidSupportedAbis
) in the Advanced section of the Android Options tab in the project property pages. - GitHub 4804: Starting in Xamarin.Android 10.3, Failed to parse APK info: failed to parse AndroidManifest.xml, error: %!s() prevented incremental deployments of certain projects that had references to libraries containing AndroidManifest.xml files.
- GitHub 4853: Starting in Xamarin.Android 10.4.0.0, error XA0030: Building with JDK version `11.0.7` is not supported. prevented using the latest available OpenJDK 11 version, such as the latest build of the JetBrains Runtime.
- For Android 11 (API level 30) emulators, failed to install Mono.Android.Platform.ApiLevel_30.apk:Failure [INSTALL_PARSE_FAILED_NO_CERTIFICATES: Scanning Failed.: No signature found in package of version 2 or newer for package Mono.Android.Platform.ApiLevel_30] prevented deploying successfully in the Debug configuration with the shared runtime enabled, which is the recommended default.
Application Mono Framework behavior on device and emulator
This version of Xamarin.Android updates the Mono 6.12 runtime and class libraries from Commit 87ef5557 to Commit 83105ba2, adding 6 new commits.
Fixes included for issues reported with Xamarin.Android applications:
- GitHub 4817: * Assertion at ... mono/mini/method-to-ir.c:12332, condition `var->opcode == OP_REGOFFSET' not met caused apps to abort in the Release configuration when attempting to use the
new()
type constraint in combination with theXElement
type.
Bindings projects
- Java.Interop GitHub 515: Bindings projects did not yet have a convenient way to add C# enumerations that did not correspond to Java types.
- Java.Interop GitHub 588: Warnings similar to warning BG8503: Invalidating Java.Util.IMap and all nested types because some of its methods were invalid. could prevent the bindings generator from providing bindings for interfaces even when the invalid methods were all marked
static
. Because classes are not required to implementstatic
methods from Java interfaces, the bindings generator now ignores invalidstatic
methods and continues generating bindings for interfaces in these cases. - Java.Interop GitHub PR 651: Unactionable warning : class-parse: warning: method ... Local variables array has 0 entries ... descriptor has 1 entries! prevented the bindings generator from detecting parameter names for constructor methods marked with the Kotlin
@JvmOverloads
annotation.
Installing
To get the new version in Visual Studio, update Visual Studio:
- Visual Studio 2019 version 16.7 Preview 4 — Visual Studio Installer
- Visual Studio 2019 for Mac 8.7 Preview 4 — Visual Studio for Mac Installer with the Preview updater channel
For other scenarios, the latest commercial .vsix and .pkg installer packages can be found in the project README.
Open source
Xamarin.Android 11.0 is based on the open-source Xamarin.Android repositories:
- The Mono runtime and class library artifacts for this version come from the android-release-Darwin-*.7z archive generated by the Mono open-source build: archive-mono/job/2020-02 build #88.
- Core JNI interaction logic is in the Java.Interop repo.
- Android bindings and MSBuild tooling are in the xamarin-android repo.
- Chat is in the
xamarin/xamarin-android
Gitter channel.