Xamarin v10.4.0.0 Release Notes

Release Date: 2020-06-23 // almost 4 years ago
  • 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:

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

    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.

    โšก๏ธ Updated XA0113 warning for Google Play submission requirements

    The XA0113 warning has been updated to reflect the current minimum target version of Android 9 (API level 28) 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 properties pages:

    warning XA0113: Google Play requires that new applications and updates must use a TargetFrameworkVersion of v9.0 (API level 28) or above. You are currently targeting v8.0 (API level 26).
    

    โšก๏ธ Mono.Data.Sqlite SQLite version update

    The version of SQLite used by Mono.Data.Sqlite in Xamarin.Android has been updated from 3.31.1 to 3.32.1, bringing in security fixes, improvements, and bug fixes.

    JI_JAVA_HOME environment variable for custom Java JDK paths

    Xamarin.Android will now look for the contents of an environment variable named JI_JAVA_HOME as another way to customize the Java JDK path used during the build. In cases where both the JI_JAVA_HOME environment variable and the JavaSdkDirectory MSBuild property are set to custom values, the MSBuild property takes precedence.

    In general, this environment does not need to be adjusted, but in certain special scenarios, having the option to customize the JDK path via an environment variable might provide useful flexibility.

    ๐Ÿ›  Issues fixed

    IDE compatibility

    • ๐Ÿ— Developer Community 1038779: Starting in Visual Studio 2019 version 16.7 Preview 1, Visual Studio would abort unexpectedly when attempting to load or build certain Xamarin.Android projects configured to use AAPT2.

    Application behavior on device and emulator

    • Developer Community 1021788, GitHub 4727: 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. This issue was also fixed in Xamarin.Android 10.3.1.4.
    • Developer Community 1030901, GitHub 4664: Localized resources from .resx files were not deployed when building and deploying from within Visual Studio to an attached device or emulator. (In contrast, clean builds on the command line worked as expected.) This issue was also fixed in Xamarin.Android 10.3.1.4.

    ๐Ÿš€ Application and library build and deployment

    • Developer Community 955972 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. This issue was also fixed in Xamarin.Android 10.3.1.4.
    • GitHub 4152: Unable to read profile ... The system cannot find the file specified prevented the FinishAotProfiling MSBuild target from completing successfully if the location of adb was not in the PATH environment variable.
    • GitHub 4542: error CS1681: You cannot redefine the global extern alias prevented building app projects successfully if the .csproj file included global in the <Aliases></Aliases> metadata element of a referenced Xamarin.Android class library.
    • GitHub 4662: In projects configured to use the recently added manifestmerger.jar Android manifest merging option, tools:node="remove" did not yet remove AndroidManifest.xml nodes generated by C# attributes in referenced library projects.
    • โšก๏ธ GitHub PR 4779: error XA1011: Using ProGuard with the D8 DEX compiler is no longer supported. Please update $(AndroidLinkTool) to r8. did not mention the corresponding term code shrinker that is used in the Visual Studio project property pages and did not mention that AndroidLinkTool is an MSBuild property.

    Android API bindings

    • ๐Ÿ‘ GitHub 4752: error XAGJS7004: System.ArgumentException: Unsupported ForegroundServiceType value '9'. prevented using bitwise combinations of multiple values of Android.Content.PM.ForegroundService.

    Application Mono Framework behavior on device and emulator

    ๐Ÿš€ This version of Xamarin.Android updates the Mono 6.12 runtime and class libraries from Commit 075c3f06 to Commit 87ef5557, adding 5 new commits.

    • GitHub 4713: Starting in Xamarin.Android 10.3, SIGSEGV during monodroid_typemap_java_to_managed could cause apps to abort if the application was built with the AndroidEnablePreloadAssemblies MSBuild property set to false.

    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: