Skip to content

Releases: dotnet/android

Xamarin.Android 11.1.0.17 Preview

20 Oct 20:03
Compare
Choose a tag to compare
Pre-release

October 20, 2020 — Xamarin.Android 11.1.0.17 was published as part of Visual Studio 2019 version 16.8 Preview 5 and Visual Studio 2019 for Mac version 8.8 Preview 5

Corresponding Visual Studio 2019 Preview release notes

What's new

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.

Issues fixed

Bindings projects

  • 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).

Installing

To get the new version in Visual Studio, update Visual Studio:

For other scenarios, the latest commercial .vsix and .pkg installer packages can be found in the project README.

Open source

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

Xamarin.Android 11.1.0.3 Preview

14 Sep 21:04
Compare
Choose a tag to compare
Pre-release

September 14, 2020 — Xamarin.Android 11.1.0.3 was published as part of Visual Studio 2019 version 16.8 Preview 3 and Visual Studio 2019 for Mac version 8.8 Preview 3.

Corresponding Visual Studio 2019 Preview release notes

What's new

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 now sets this attribute it 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>

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.

Issues fixed

Application and library build and deployment

  • 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 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.

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

  • 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 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 4989: Calling this.Dispose() from within a Java.Lang.Object.Dispose(bool) override threw a System.ArgumentException.

Bindings projects

  • 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.
    

Installing

To get the new version in Visual Studio, update Visual Studio:

For other scenarios, the latest commercial .vsix and .pkg installer packages can be found in the project README.

Open source

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

Xamarin.Android 11.0.99.34 Preview

26 Aug 02:10
Compare
Choose a tag to compare
Pre-release

August 25, 2020 — Xamarin.Android 11.0.99.34 was published as part of Visual Studio 2019 version 16.8 Preview 2 and Visual Studio 2019 for Mac version 8.8 Preview 2.

Corresponding Visual Studio 2019 Preview release notes

What's new

Build and deployment performance in Xamarin.Android 11.0.99.34

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.

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.

Issues fixed and other small changes in Xamarin.Android 11.0.99.34

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 buidling successfully in the Release configuration if the managed linker was disabled in that configuration.
  • 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 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.

Application behavior on device and emulator

  • 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.

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.

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.

Installing

To get the new version in Visual Studio, update Visual Studio:

For other scenarios, the latest commercial .vsix and .pkg installer packages can be found in the project README.

Open source

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

Xamarin.Android 11.0.2.0

19 Aug 14:18
Compare
Choose a tag to compare

August 18, 2020 — Xamarin.Android 11.0.2.0 was published as part of in Visual Studio 2019 version 16.7.2 and Visual Studio 2019 for Mac version 8.7.3.

Issues fixed in Xamarin.Android 11.0.2.0

Application behavior on device and emulator

  • Developer Community 1139203, GitHub 4983: Starting in Xamarin.Android 11.0, 'Could not load library: Library '/system/lib64/libmonodroid.so' not found.' ... Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR) prevented some application projects from launching successfully in certain build configurations.

Installing

To get the new version in Visual Studio, update Visual Studio:

For other scenarios, the latest commercial .vsix and .pkg installer packages can be found in the project README.

Versions for continuous build environments

For users installing Xamarin.Android on macOS continuous build environments, the corresponding version of the Mono Framework MDK to use is Mono Framework MDK 6.12.0.89.

For special scenarios where project authors require Xamarin.Android SDK version 11.0.2.0 without any subsequent 11.0 servicing fixes, the fixed-version Visual Studio 2019 version 16.7.2 BuildTools installer can be used on Windows and the fixed-version .pkg installer package can be used on macOS. The fixed-version .vsix installer package is another alternative for Windows.

Open source

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

Xamarin.Android 11.0.99.9 Preview

05 Aug 19:43
Compare
Choose a tag to compare
Pre-release

August 5, 2020 — Xamarin.Android 11.0.99.9 was published as part of Visual Studio 2019 version 16.8 Preview 1 and Visual Studio 2019 for Mac version 8.8 Preview 1.

Corresponding Visual Studio 2019 Preview release notes

What's new

Soft deprecation of undocumented ProguardConfigFiles MSBuild property

Since back when ProGuard compatibility was originally added to Xamarin.Android, the feature has included an undocumented ProguardConfigFiles MSBuild property that could be used as an alternative to the ProguardConfiguration Build Action.

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 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

Application and library build and deployment

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.

Bindings projects

  • Java.Interop GitHub PR 672: Nested Java types with protected visibility within sealed types are now generated with private visibility, avoiding C# warning CS0628.

Thank you

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

Installing

To get the new version in Visual Studio, update Visual Studio:

For other scenarios, the latest commercial .vsix and .pkg installer packages can be found in the project README.

Open source

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

Xamarin.Android 11.0.0.3

05 Aug 19:22
Compare
Choose a tag to compare

August 5, 2020 — Xamarin.Android 11.0.0.3 was published as part of Visual Studio 2019 version 16.7 and Visual Studio 2019 for Mac version 8.7.

Corresponding Visual Studio 2019 release notes

What's new compared to Xamarin.Android 10.3

Deprecations, removals, and default configuration changes

Build and deployment performance

  • GitHub PR 4190: Switch to running AAPT2 in single-file mode rather than --dir mode. This reduced the total incremental build time from about 16.4 seconds to about 5.5 seconds for a test project when a single Android resource file was changed between builds.
  • GitHub PR 4750: Skip checking for uses of AppDomain.CreateDomain() in assemblies provided by Xamarin.Android. This reduced the time for the LinkAssembliesNoShrink from about 2.6 seconds to about 1.8 seconds for an initial clean build of small Xamarin.Forms test app.
  • Java.Interop GitHub PR 624, Java.Interop GitHub PR 627, Java.Interop GitHub PR 628: Update the CRC-64 algorithm used during builds to take advantage of a more efficient calculation technique. This reduced the total incremental build time from about 8.7 seconds to about 8.5 seconds for a small Xamarin.Forms app when one line of a C# file was changed between builds.

Smaller app package sizes

Managed assemblies are now compressed by default for Release configuration builds, resulting in significantly smaller APK and Android App Bundle sizes. Assemblies are compressed with the LZ4 algorithm during builds and then decompressed on device during app startup.

For a small example Xamarin.Forms application, this reduced the APK size from about 23 megabytes to about 17 megabytes while only increasing the time to display the first page of the app from about 780 milliseconds to about 790 milliseconds.

If needed, the new behavior can be disabled for a particular project by opening the project file in Visual Studio or another text editor and setting the AndroidEnableAssemblyCompression MSBuild property to false in the .csproj file:

<PropertyGroup>
  <AndroidEnableAssemblyCompression>false</AndroidEnableAssemblyCompression>
</PropertyGroup>

Note: This feature is intended to replace the older Bundle assemblies into native code Visual Studio Enterprise feature for purposes of app size savings. The AndroidEnableAssemblyCompression property takes precedence if both features are enabled. Project authors who no longer need the Bundle assemblies into native code feature can now disable it or remove the BundleAssemblies MSBuild property from the .csproj file:

 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
   <DebugSymbols>True</DebugSymbols>
   <DebugType>portable</DebugType>
   <Optimize>True</Optimize>
   <OutputPath>bin\Release\</OutputPath>
   <DefineConstants>TRACE</DefineConstants>
   <ErrorReport>prompt</ErrorReport>
   <WarningLevel>4</WarningLevel>
   <AndroidManagedSymbols>true</AndroidManagedSymbols>
   <AndroidUseSharedRuntime>False</AndroidUseSharedRuntime>
   <AndroidLinkMode>SdkOnly</AndroidLinkMode>
   <EmbedAssembliesIntoApk>True</EmbedAssembliesIntoApk>
-  <BundleAssemblies>true</BundleAssemblies>
 </PropertyGroup>

Background information

For comparison, for the small test Xamarin.Forms application with all target ABIs enabled, the Bundle assemblies into native code feature increases the APK size from about 23 megabytes to about 26 megabytes while increasing the time to display the first page of the app from about 780 milliseconds to about 850 milliseconds.

If only one target ABI is enabled for the test application, such as arm64-v8a, the Bundle assemblies into native code feature decreases the APK size from around 16 megabytes to around 7.5 megabytes, while the new LZ4 approach decreases the size to around 8 megabytes. Time to display the first page is the same in this case as with all target ABIs enabled.

The number of target ABIs affects the size comparison because Bundle assemblies into native code uses a separate copy of the compressed assemblies for each ABI, while the new LZ4 approach shares them across all target ABIs.

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.

New features

These bindings take advantage of C# 8.0's support for default and static interface members to provide C# interface APIs that more closely match the original Android APIs.

For example, in the Android.Views.TextClassifiers namespace, TextClassifier.HintTextIsEditable is now available as ITextClassifier.HintTextIsEditable, and the old TextClassifier.HintTextIsEditable field is marked [Obsolete].

Note: An older set of bindings for interface constants were also available in Consts classes like TextClassifierConsts in earlier target framework versions. Those classes were marked [Obsolete] for several years. They have been removed completely for the Android 11 (R) target framework version. Project authors are encouraged to switch to the new interface members like ITextClassifier.HintTextIsEditable at their earliest convenience.

Preliminary Java JDK 11 compatibility

Xamarin.Android can now use Java JDK 11 to build libraries and applications.

JDK 11 is not yet installed or required by default for Xamarin.Android, but the apksigner tool in Android SDK Build-Tools version 30 does require JDK 11, so project authors who are using the [bindings for Android 11 Beta][android-11-bindings] and want to experiment with setting the AndroidSdkBuildToolsVersion MSBuild property to version 30.0.0 or higher will need to use JDK ...

Read more

Xamarin.Android 11.0.0.3 Preview

14 Jul 22:17
Compare
Choose a tag to compare
Pre-release

July 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

Deprecations, removals, and default configuration changes

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

Read more

Xamarin.Android 10.4.0.0

23 Jun 20:51
Compare
Choose a tag to compare
Pre-release

June 23, 2020 — Xamarin.Android 10.4.0.0 was published as part of Visual Studio 2019 version 16.7 Preview 3 and Visual Studio 2019 for Mac version 8.7 Preview 3.

Corresponding Visual Studio 2019 Preview release notes

In Xamarin.Android 10.4.0.0

Deprecations, removals, and default configuration changes

Build and deployment performance

  • GitHub PR 4750: Skip checking for uses of AppDomain.CreateDomain() in assemblies provided by Xamarin.Android. This reduced the time for the LinkAssembliesNoShrink from about 2.6 seconds to about 1.8 seconds for an initial clean build of small Xamarin.Forms test app.

Smaller app package sizes

Managed assemblies are now compressed by default for Release configuration builds, resulting in significantly smaller APK and Android App Bundle sizes. Assemblies are compressed with the LZ4 algorithm during builds and then decompressed on device during app startup.

For a small example Xamarin.Forms application, this reduced the APK size from about 23 megabytes to about 17 megabytes while only increasing the time to display the first page of the app from about 780 milliseconds to about 790 milliseconds.

If needed, the new behavior can be disabled for a particular project by opening the project file in Visual Studio or another text editor and setting the AndroidEnableAssemblyCompression MSBuild property to false in the .csproj file:

<PropertyGroup>
  <AndroidEnableAssemblyCompression>false</AndroidEnableAssemblyCompression>
</PropertyGroup>

Note: This feature is intended to replace the older Bundle assemblies into native code Visual Studio Enterprise feature for purposes of app size savings. The AndroidEnableAssemblyCompression property takes precedence if both features are enabled. Project authors who no longer need the Bundle assemblies into native code feature can now disable it or remove the BundleAssemblies MSBuild property from the .csproj file:

 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
   <DebugSymbols>True</DebugSymbols>
   <DebugType>portable</DebugType>
   <Optimize>True</Optimize>
   <OutputPath>bin\Release\</OutputPath>
   <DefineConstants>TRACE</DefineConstants>
   <ErrorReport>prompt</ErrorReport>
   <WarningLevel>4</WarningLevel>
   <AndroidManagedSymbols>true</AndroidManagedSymbols>
   <AndroidUseSharedRuntime>False</AndroidUseSharedRuntime>
   <AndroidLinkMode>SdkOnly</AndroidLinkMode>
   <EmbedAssembliesIntoApk>True</EmbedAssembliesIntoApk>
-  <BundleAssemblies>true</BundleAssemblies>
 </PropertyGroup>

Background information

For comparison, for the small test Xamarin.Forms application with all target ABIs enabled, the Bundle assemblies into native code feature increases the APK size from about 23 megabytes to about 26 megabytes while increasing the time to display the first page of the app from about 780 milliseconds to about 850 milliseconds.

If only one target ABI is enabled for the test application, such as arm64-v8a, the Bundle assemblies into native code feature decreases the APK size from around 16 megabytes to around 7.5 megabytes, while the new LZ4 approach decreases the size to around 8 megabytes. Time to display the first page is the same in this case as with all target ABIs enabled.

The number of target ABIs affects the size comparison because Bundle assemblies into native code uses a separate copy of the compressed assemblies for each ABI, while the new LZ4 approach shares them across all target ABIs.

Minimum compatible Android version changed back to Android 4.4 KitKat (API level 19)

The minimum compatible Android version for Xamarin.Android apps has been changed back to Android Android 4.4 KitKat (API level 19) to align more closely with the Xamarin.Forms supported platforms.

This reverts the change from the previous preview that updated the minimum compatible version to Android 5.0 Lollipop.

Enumerations for new constants in Android 11 Developer Preview 4

The preview bindings for Android 11 Developer Preview 4 now provide strongly typed enumerations for new constants that are part of Android 11.

Preliminary Java JDK 11 compatibility

Xamarin.Android can now use Java JDK 11 to build libraries and applications.

JDK 11 is not yet installed or required by default for Xamarin.Android, but the apksigner tool in Android SDK Build-Tools version 30 does require JDK 11, so project authors who are using the preview bindings for Android 11 Developer Preview 4 and want to experiment with setting the AndroidSdkBuildToolsVersion MSBuild property to version 30.0.0 will need to use JDK 11.

To do so:

  1. Install a distribution of JDK 11 version 11.0.4 or lower, such as JetBrains Runtime jbrsdk build 520.13 or earlier.

  2. On Windows, open Tools > Options in Visual Studio, select the Xamarin > Android Settings node, and set Java Development Kit Location to the root of the JDK 11 installation.

    On macOS, open Visual Studio > Preferences, select the Projects > SDK Locations > Android node, open the Locations tab, and set the Java SDK (JDK) Location to the root of the JDK 11 installation.

    Alternatively, to configure the JDK path per project, open the project file in Visual Studio or another text editor and set the JavaSdkDirectory MSBuild property to the root of the JDK 11 installation. For example:

    <PropertyGroup>
      <JavaSdkDirectory>C:\Program Files\jbrsdk</JavaSdkDirectory>
    </PropertyGroup>

Known Issues

  • GitHub 4789: error XACLP7004: System.ArgumentException: Directory ... obj\Debug\javadocs...' does not appear to be an android doc reference directory. prevents using the JavaSourceJar Build Action in bindings projects.
  • GitHub 4853: error XA0030: Building with JDK version `11.0.7` is not supported. prevents using the latest available OpenJDK 11 version, such as the latest build of the JetBrains Runtime.

XA1023 warning for upcoming DX DEX compiler deprecation

Projects that have Dex compiler set to dx in the Visual Studio project property pages will now get a build warning:

warning XA1023: Using the DX DEX Compiler is deprecated. Please update `$(AndroidDexTool)` to `d8`.

To resolve this warning, set the Dex compiler in the Visual Studio project property pages to d8, or edit the project file in Visual Studio or another text editor and set the AndroidDexTool MSBuild property to d8:

<PropertyGroup>
  <AndroidDexTool>d8</AndroidDexTool>
</PropertyGroup>

Background information

Google has deprecated the DX DEX compiler in favor of the D8 DEX compiler. After February 1, 2021, DX will no longer be a part of the Android SDK or Android Studio. Project authors are encouraged to migrate their projects to D8 at their earliest convenience to prepare for this change.

Read more

Xamarin.Android 10.3.99.259

03 Jun 01:19
Compare
Choose a tag to compare
Pre-release

June 2, 2020 — Xamarin.Android 10.3.99.259 was published as part of Visual Studio 2019 version 16.7 Preview 2 and Visual Studio 2019 for Mac version 8.7 Preview 2.

Corresponding Visual Studio 2019 Preview release notes

In Xamarin.Android 10.3.99.259

Deprecations, removals, and default configuration changes

Minimum compatible Android version now Android 5.0 Lollipop (API level 21)

The minimum compatible Android version for Xamarin.Android apps is now Android 5.0 Lollipop (API level 21).

Error XA0001 will now appear for projects that have an earlier target framework version set under Compile using Android version: (Target Framework) in the Visual Studio project properties pages:

error XA0001: Unsupported or invalid $(TargetFrameworkVersion) value of 'v4.4'. Please update your Project Options.

Simiarly, warning XA4216 will now appear for projects that have an earlier version set for the minSdkVersion in the AndroidManifest.xml file:

warning XA4216: AndroidManifest.xml //uses-sdk/@android:minSdkVersion '20' is less than API-21, this configuration is not supported.

Background information

The unmanaged native libraries that are part of Xamarin.Android are now built to target Android 5.0 Lollipop (API level 21), so apps built using this release can abort due to incompatible APIs if run on earlier Android versions.

Preview bindings for Android 11 Developer Preview 4

This version includes preview bindings for the fourth Developer Preview of Android 11 from Google. See the Android 11 Developer Preview documentation for additional information about the behavior and API changes in this new Android version. To try the bindings for the new APIs in a Xamarin.Android project, set Compile using Android version: (Target Framework) to Android 10.0.99 (R) under the Application tab of the Visual Studio project property pages. This sets the TargetFrameworkVersion property to v10.0.99 in the .csproj file:

<TargetFrameworkVersion>v10.0.99</TargetFrameworkVersion>

Bindings projects support for methods with more than 14 parameters

Xamarin.Android bindings projects now support binding Java methods that have any number of parameters instead of the previous limit of 14.

D8 and R8 version update to 1.6.82

The version of the D8 DEX compiler and R8 code shrinker included in Xamarin.Android has been updated from 1.5.68 to 1.6.82.

bundletool version update to 0.14.0

The version of the bundletool executable included in Xamarin.Android has been updated from 0.10.2 to 0.14.0, bringing in several improvements and bug fixes.

ProGuard version update to 6.2.2

The version of ProGuard included in Xamarin.Android has been updated from 5.3.2 to 6.2.2, bringing in a number of improvements and bug fixes.

Note: ProGuard is only relevant for projects configured to use the older DX DEX compiler. Project authors are recommended to update to the newer D8 DEX compiler at their earliest convenience.

Issues fixed

Application behavior on device and emulator

  • Developer Community 1024028, GitHub 4596, GitHub 4660: In Xamarin.Android 10.3.99.230, System.MemberAccessException: Cannot create an instance of ... could cause apps to abort when attempting to use certain APIs that have both generic and non-generic versions.
  • GitHub 3784, GitHub 4471: An outdated version of the Mono Shared Runtime package was sometimes left on target development devices and emulators after Xamarin.Android version updates. This could result in unexpected behaviors in Debug configuration apps until the old shared runtime was manually uninstalled.
  • GitHub PR 4589: ObjectDisposedException could in theory be thrown during cancellation of AndroidClientHandler requests, depending on the particular timing of cancellation and object disposal. The time window where this can happen is now narrower.

Application and library build and deployment

  • GitHub PR 4640: System.ArgumentException: Illegal characters in path could prevent successful automatic detection of the Android SDK location during builds in some cases if an AndroidSdkDirectory registry value was set for Xamarin.Android that contained unexpected characters. One possible cause of this issue has now been addressed.

IDE compatibility

  • GitHub 4675: The project ... is missing Android SDKs required for building. prevented building without the Android NDK installed for projects with Enable Startup Tracing or AOT Compilation enabled.

Bindings projects

  • Java.Interop GitHub 631: Xamarin.Android bindings projects did not yet support binding Java methods with more than 14 parameters.

Installing

To get the new version in Visual Studio, update Visual Studio:

For other scenarios, the latest commercial .vsix and .pkg installer packages can be found in the project README.

Open source

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

Xamarin.Android 10.3.1.4

01 Jun 21:38
Compare
Choose a tag to compare

June 2, 2020 — Xamarin.Android 10.3.1.4 was published as part of Visual Studio 2019 for Mac version 8.6.2.

June 1, 2020 — Xamarin.Android 10.3.1.4 was published as part of Visual Studio 2019 version 16.6.1.

Issues fixed in Xamarin.Android 10.3.1.4

Application and library build and deployment

  • Developer Community 955972 Starting in Xamarin.Android 10.3, error APT2258: not well-formed (invalid token) prevented using accented characters or other non-ASCII UTF-8 characters in Android layout files that also contained custom views.
  • Developer Community 955972 Starting in Xamarin.Android 10.3, errors similar to error XARLC7000: System.Xml.XmlException: Invalid character in the given encoding could prevent successful builds for certain project configurations, such as projects located in directory paths that contained accented characters or other non-ASCII UTF-8 characters.

Application behavior on device and emulator

  • Developer Community 1021788: GitHub 4727: Starting in Xamarin.Android 10.3, many typemap: unable to find mapping to a Java type from managed type messages were logged to the application output for running apps, in some cases causing Visual Studio to become unresponsive until the output window caught up.
  • Developer Community 1030901, GitHub 4664: Starting in Xamarin.Android 10.3, localized resources from .resx files 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.)

Installing

To get the new version in Visual Studio, update Visual Studio:

For other scenarios, the latest commercial .vsix and .pkg installer packages can be found in the project README.

Versions for continuous build environments

For users installing Xamarin.Android on macOS continuous build environments, the corresponding version of the Mono Framework MDK to use is Mono Framework MDK 6.10.0.104.

For special scenarios where project authors require Xamarin.Android SDK version 10.3.1.4 without any subsequent 10.3 servicing fixes, the fixed-version Visual Studio 2019 version 16.6.1 BuildTools installer can be used on Windows and the fixed-version .pkg installer package can be used on macOS. The fixed-version .vsix installer package is another alternative for Windows.

Open source

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