Releases: dotnet/android
Xamarin.Android 11.0.99.34 Preview
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
- Deprecation of Android Wear references in app projects
- Issues fixed and other small changes
- Installing
- Open source
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 totrue
. - 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:
- Visual Studio 2019 version 16.8 Preview 2 — Visual Studio Installer
- Visual Studio 2019 for Mac 8.8 Preview 2 — 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.1 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 #android channel on the DotNetEvolution Discord server.
Xamarin.Android 11.0.2.0
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:
- Visual Studio 2019 version 16.7.2 — Visual Studio Installer
- Visual Studio 2019 for Mac version 8.7.3 — Visual Studio for Mac Installer with the Stable updater channel
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:
- 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 #android channel on the DotNetEvolution Discord server.
Xamarin.Android 11.0.99.9 Preview
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
- Issues fixed and other small changes
- Installing
- Thank you
- Open source
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
- GitHub 4818: Projects that had the undocumented
AndroidAotMode
MSBuild property set to the experimentalHybrid
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.
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 withinsealed
types are now generated withprivate
visibility, avoiding C# warning CS0628.
Thank you
A big Thank You! to community members who contributed improvements in this
release:
- Mohamed Akram (@mohd-akram), GitHub PR 4747: Add support for building xamarin-android source checkouts on Fedora.
Installing
To get the new version in Visual Studio, update Visual Studio:
- Visual Studio 2019 version 16.8 Preview 1 — Visual Studio Installer
- Visual Studio 2019 for Mac 8.8 Preview 1 — 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.1 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 #android channel on the DotNetEvolution Discord server.
Xamarin.Android 11.0.0.3
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
- Build and deployment performance
- Smaller app package sizes
- Bindings for Android 11 Beta
- Preliminary Java JDK 11 compatibility
- Mono.Android nullable reference types compatibility
- Tidier IntelliSense suggestions for Java.Lang.Object subclasses
- Bindings projects support for methods with more than 14 parameters
- Bindings projects enumeration enhancements
- JI_JAVA_HOME environment variable for custom Java JDK paths
- Issues fixed
- Installing
- Thank you
- Open source
Deprecations, removals, and default configuration changes
- Assemblies compressed by default in Release configuration
- XA1023 warning for upcoming DX DEX compiler deprecation
- Other warning and error changes
- Tool and library version updates
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 theLinkAssembliesNoShrink
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 ...
Xamarin.Android 11.0.0.3 Preview
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
- 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](https://developercommunity.visualstudio.com/content/problem/1061307/index.htm...
Xamarin.Android 10.4.0.0
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
- Build and deployment performance
- Smaller app package sizes
- Minimum compatible Android version changed back to Android 4.4 KitKat (API level 19)
- Enumerations for new constants in Android 11 Developer Preview 4
- Preliminary Java JDK 11 compatibility
- Mono.Data.Sqlite SQLite version update
- JI_JAVA_HOME environment variable for custom Java JDK paths
- Issues fixed
- Installing
- Open source
Deprecations, removals, and default configuration changes
- XA1023 warning for upcoming DX DEX compiler deprecation
- Updated XA0113 warning for Google Play submission requirements
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 theLinkAssembliesNoShrink
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.
Xamarin.Android 10.3.99.259
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
- Preview bindings for Android 11 Developer Preview 4
- Bindings projects support for methods with more than 14 parameters
- D8 and R8 version update to 1.6.82
- bundletool version update to 0.14.0
- ProGuard version update to 6.2.2
- Issues fixed
- Installing
- Open source
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 ofAndroidClientHandler
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:
- Visual Studio 2019 version 16.7 Preview 2 — Visual Studio Installer
- Visual Studio 2019 for Mac 8.7 Preview 2 — 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 10.4 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 #76.
- 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.
Xamarin.Android 10.3.1.4
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:
- Visual Studio 2019 version 16.6.1 — Visual Studio Installer
- Visual Studio 2019 for Mac version 8.6.2 — Visual Studio for Mac Installer with the Stable updater channel
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:
- 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 #66.
- 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.
Xamarin.Android 10.3.99.230
May 19, 2020 — Xamarin.Android 10.3.99.230 was published as part of Visual Studio 2019 version 16.7 Preview 1 and Visual Studio 2019 for Mac version 8.7 Preview 1.
Corresponding Visual Studio 2019 Preview release notes
What's new
- Build and deployment performance
- Mono.Android nullable reference types compatibility
- Tidier IntelliSense suggestions for Java.Lang.Object subclasses
- Issues fixed
- Known issues
- Installing
- Thank you
- Open source
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. - 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.
Mono.Android nullable reference types compatibility
The Mono.Android assembly has been annotated for compatibility with C# 8.0 nullable reference type checks. Projects can now optionally place code that uses types from Mono.Android in a nullable context to take advantage of additional compiler nullability checks. For example, to enable nullability checks for all code in a project, set the Nullable
MSBuild property to enable
in the .csproj file:
<PropertyGroup>
<Nullable>enable</Nullable>
</PropertyGroup>
When this property set, the build will emit warnings if any code does not properly account for possible null
values passed into or returned from APIs in the Mono.Android assembly.
See the nullable reference types documentation for more information.
Note: The majority of Mono.Android, including the nullability annotations, is automatically generated from the Android Java source. The annotations intentionally preserve any upstream bugs in the nullability information provided by the Android source code.
Tidier IntelliSense suggestions for Java.Lang.Object subclasses
Java.Lang.Object
contains several properties and methods that are required to be public
to support Xamarin.Android Java bindings but are not intended to be used in hand-written code. These members are now hidden from IntelliSense, making it easier to find the useful members.
Bindings projects XA4231 and XA4232 warnings for deprecated settings
XA4231 warning for deprecated jar2xml parser
Any bindings project that has the AndroidClassParser
MSBuild property set to the old jar2xml
parser or any other unrecognized value will now get a XA4231 build warning:
warning XA4231: The Android class parser 'jar2xml' is deprecated and will be removed in a future version of Xamarin.Android. Update the project properties to use 'class-parse' instead.
To resolve this warning, update the Android Class Parser setting in the Visual Studio project property pages or the .jar file parser setting in Visual Studio for Mac to class-parse. This corresponds to the class-parse
value for the AndroidClassParser
MSBuild property in the .csproj file:
<PropertyGroup>
<AndroidClassParser>class-parse</AndroidClassParser>
</PropertyGroup>
XA4232 warning for deprecated XamarinAndroid code generation target
Any bindings project that has the AndroidCodegenTarget
MSBuild property set to the old XamarinAndroid
code generation target or any other unrecognized value will now get a XA4232 build warning:
warning XA4232: The Android code generation target value 'XamarinAndroid' is deprecated and will be removed in a future version of Xamarin.Android. Update the project properties to use 'XAJavaInterop1'.
To resolve this warning, update the Android Codegen target setting in the Visual Studio project property pages or the Code generation target setting in Visual Studio for Mac to XAJavaInterop1. This corresponds to the XAJavaInterop1
value for the AndroidCodegenTarget
MSBuild property in the .csproj file:
<PropertyGroup>
<AndroidCodegenTarget>XAJavaInterop1</AndroidCodegenTarget>
</PropertyGroup>
Issues fixed in Xamarin.Android 10.3.99.230
Application and library build and deployment
- GitHub 2042: The Mono.Android assembly did not yet surface the nullability information provided by the upstream Android source code for use in C# 8.0 nullable contexts.
- GitHub 4439: Invalid values of the
AndroidDexTool
MSBuild property produced a misleading error during deployment instead of an error during the build. Invalid values are now ignored and the default D8 DEX tool is used instead. - GitHub PR 4578: The source directory is under the output directory. Skip it. build error did not yet mention the relevant MSBuild item type or the current path of the invalid item.
- Java.Interop GitHub PR 622: warning : Failed to read ... with debugging symbols. Retrying to load it without it. and Mono.Cecil.Cil.SymbolsNotMatchingException: Symbols were found but are not matching the assembly could appear during builds, for example for projects using obfuscation tools. To align more closely with the behavior of other common .NET project types that do not warn about mismatched debugger symbols, Xamarin.Android projects now log these as informational messages instead of warnings.
Design-time builds
- Developer Community 896179, GitHub 4273: The IDE could become unresponsive for tens of seconds after changes were saved to an Android layout file in projects configured to use AAPT2.
Bindings projects
- GitHub PR 4579: Unrecognized transform root element build error did not yet mention the relevant MSBuild item type.
- GitHub PR 4579: Specified source jar not found and Specified reference jar not found build errors did not yet mention Java library types other than JAR files.
- Java.Interop GitHub PR 611: Building a binding project that had a reference to another binding project performed some redundant work for assemblies referenced by both projects.
Application Mono Framework behavior on device and emulator
This version of Xamarin.Android updates the Mono 6.12 runtime and class libraries from Commit 165f4b03 to Commit 051408e0, adding 5 new commits.
Fixes included for issues reported with Xamarin.Android applications:
- Developer Community 952568, Mono GitHub 18865: Starting in Xamarin.Android 10.2,
SslStream.BeginRead()
andSslStream.BeginWrite()
would block if called at the same time.
IDE compatibility
- GitHub 4582: Some
Java.Lang.Object
properties and methods likeHandle
andPeerReference
appeared in IntelliSense suggestions even though they were primarily intended for use only in generated code.
Known issues in Xamarin.Android 10.3.99.230
- [Developer Community 1024028](https://developercommunity.visual...
Xamarin.Android 10.3.1.0
May 19, 2020 — Xamarin.Android 10.3.1.0 was published as part of Visual Studio 2019 version 16.6 and Visual Studio 2019 for Mac version 8.6.
Corresponding Visual Studio 2019 release notes
What's new compared to Xamarin.Android 10.2
- Build and deployment performance
- App startup performance
- Android resource editing performance
- Mono Framework version update to 6.12
- Preview bindings for Android 11 Developer Preview 2
- R8 configured to suppress common build errors
- More thorough clean of obj directory between builds
- Compatibility with embedded debug information
- Support for Android App Bundle configuration files
- Stream.Seek() for file streams from Android APIs
- Localized errors and warnings for builds
- Java.Interop nullable reference types compatibility
- Mono.Data.Sqlite SQLite version update
- Issues fixed
- Installing
- Thank you
- Open source
Deprecations, removals, and default configuration changes
- Default Android tools versions update to 29.0
- XA1011 error for D8 with ProGuard
- XA0122 and CS0618 warnings for deprecated Java.Interop.DoNotPackageAttribute
- CS0619 error for obsolete constant fields
- Bindings projects exclusion of private nested types
- Removal of AndroidExplicitCrunch feature
- Removal of F# Resource.designer.fs file support
- Removal of keystore certificate fingerprint from build output
- Removal of .exe reference support
Build and deployment performance
- GitHub PR 3885: Adjust caching of device information during the build so it covers the case where no device or emulator is found. This reduced the time for the
DetectIfAppWasUninstalled
task from about 2 seconds to about 0 seconds, bringing the total time down closer to the time for a build where a device or emulator is available. - GitHub PR 3999: Allow
BuildApk
to merge new files into the previous APK instead of generating a new APK from scratch for incremental builds where an Android resource file has changed. This reduced the incremental build time for theBuildApk
step from about 4 seconds to about 0.7 seconds for a small test app when one Android resource file was changed between builds. - GitHub PR 4158: Update the default order of strategies used to detect installed packages to minimize time for modern devices. This can potentially save about 100 milliseconds for the first deployment of an app after launching Visual Studio.
- GitHub PR 4215: Remove a redundant call to the
ResolveAssemblyReference
task during the_ResolveSatellitePaths
target. This reduced the total time spent in calls toResolveAssemblyReference
from about 240 milliseconds to about 150 milliseconds for incremental builds of a medium sized project. The same savings also apply to the deployment step, resulting in an approximate combined savings of 180 milliseconds for build and deployment of the test project. - GitHub PR 4236: Use a
Lazy<T>
type to access the NuGet lock file so it is only loaded when needed, and remove some redundant logging messages. This reduced the total time for theResolveAssemblies
task from about 320 milliseconds to about 240 milliseconds for incremental builds of a medium sized project. The same savings also apply to the deployment step, resulting in an approximate combined savings of 160 milliseconds for build and deployment of the test project. - GitHub PR 4251: Reuse
MemoryStream
instances throughout the Xamarin.Android build targets to save on allocations. This reduced the combined time for the_GenerateJavaStubs
,_ResolveLibraryProjectImports
, and_GeneratePackageManagerJava
targets from about 3.3 seconds to about 3.0 seconds for an incremental build of a test app where theMainActivity
type was modified between builds. - GitHub PR 4260: Remove unneeded calls to
string.Format()
during theLinkAssembliesNoShrink
task. This reduced the time for the task from about 800 milliseconds to about 770 milliseconds for an initial clean build of a small Xamarin.Forms test app. - GitHub PR 4268, Java.Interop GitHub PR 570: Implement and switch to a new set of wrapper methods around the Mono.Cecil methods to allow caching the results during the
GenerateJavaStubs
task. This reduced the time for the task from about 1.4 seconds to about 0.9 seconds for an initial clean build of small test Xamarin.Forms test app. - GitHub PR 4303: Replace string interpolation during typemap assembly code generation in
GenerateJavaStubs
with sequential calls toStreamWriter.Write()
. This reduced the total time forGenerateJavaStubs
from about 1.3 seconds to about 0.9 seconds for an initial clean build of a small Xamarin.Forms test app. - GitHub PR 4308: Skip executing
keytool -list
during theSignAndroidPackage
target. This saved about 200 milliseconds for theSignAndroidPackage
target for incremental builds where a new APK was generated, such as after changing an Android resource. - GitHub PR 4316: Switch the
LinkAssembliesNoShrink
task to take advantage of the caching from the new Mono.Cecil wrapper methods introduced in Java.Interop GitHub PR 570. This reduced the time for the task from about 710 milliseconds to about 700 milliseconds for an initial clean build of a small Xamarin.Forms test app. - GitHub PR 4320: Update the version of LibZipSharp used by the build tasks to 1.0.10, which switches several
byte[]
instances toSystem.Buffers.ArrayPool
instances to save on allocations. This reduced the combined time for theResolveLibraryProjectImports
andBuildApk
tasks from about 5.3 seconds to about 5.0 seconds for a small test Xamarin.Forms app on an initial clean build. - GitHub PR 4395: Remove use of temporary files during the
ConvertResourcesCases
task. This reduced the time for the task from about 610 milliseconds to about 510 milliseconds for a moderately large real-world project on initial clean builds as well as on incremental builds with Android resource changes. - Java.Interop GitHub PR 559: Switch from using
Assembly.GetName().Name
to usingAssembly.FullName
combined withstring.Substring()
inJavaNativeTypeManager.GetPackageName()
. This reduced the time forGenerateJavaStubs
from about 390 milliseconds to about 360 milliseconds for an initial clean build of a small Xamarin.Forms test app. - Java.Interop GitHub PR 577: Change a LINQ expression to a loop in Java.Interop's
IsSubclassOf()
extension method. This reduced the time forGenerateJavaStubs
from about 560 milliseconds to about 540 milliseconds for an initial clean build of a small Xamarin.Forms test app. - Java.Interop GitHub PR 596: Use
File.Exists()
instead ofDirectoryGetFile()
in a few places. This reduced the time for theLinkAssembliesNoShrink
task from about 710 milliseconds to about 430 milliseconds for a small test Xamarin.Forms app on an initial clean build.
App startup performance
- GitHub PR 3958: Skip scanning for .exe files during app startup because Xamarin.Android apps only expect .dll assemblies. This reduced the
Runtime.init()
phase of application startup for a small test app from about 165 milliseconds to about 164 milliseconds on a Google Pixel 3 XL device and from about 530 milliseconds to about 450 milliseconds on an x86 emulator using HAXM. - [GitHub PR 3992](https://gith...