Releases: dotnet/android
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...
Xamarin.Android 10.3.1.0 Preview
May 14, 2020 — Xamarin.Android 10.3.1.0 was published as part of Visual Studio 2019 for Mac version 8.6 Preview 6.
Corresponding Visual Studio 2019 release notes
Issues fixed in Xamarin.Android 10.3.1.0
Application and library build and deployment
- Developer Community 1024028, GitHub 4596, GitHub 4660: Starting in Xamarin.Android 10.2.100.7, 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.
Installing
To get the new version in Visual Studio, update Visual Studio:
- Visual Studio 2019 for Mac version 8.6 Preview 6 — Visual Studio for Mac Installer with the Preview updater channel
For other scenarios, the commercial .pkg installer package can be found in the project README.
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.0.80
May 7, 2020 — Xamarin.Android 10.3.0.80 was published as part of Visual Studio 2019 for Mac version 8.6 Preview 5
April 30, 2020 — Xamarin.Android 10.3.0.80 was published as part of Visual Studio 2019 version 16.6 Preview 5
Corresponding Visual Studio 2019 Preview release notes
What's new
This version adds a few more localized warnings and errors for builds to the initial set.
Installing
To get the new version in Visual Studio, update Visual Studio:
- Visual Studio 2019 version 16.6 Preview 5 — Visual Studio Installer
- Visual Studio 2019 for Mac version 8.6 Preview 5 — 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.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.0.74
April 17, 2020 — Xamarin.Android 10.3.0.74 was published to the Preview updater channel of Visual Studio 2019 for Mac version 8.6 Preview 2
April 16, 2020 — Xamarin.Android 10.3.0.74 was published as part of Visual Studio 2019 version 16.6 Preview 3
Corresponding Visual Studio 2019 Preview release notes
What's new
- Preview bindings for Android 11 Developer Preview 2
- App startup performance
- R8 configured to suppress common build errors
- XA1011 error for D8 with ProGuard
- More aggressive incremental clean of obj directory for certain scenarios
- Issues fixed
- Installing
- Open source
Preview bindings for Android 11 Developer Preview 2
This version includes preview bindings for the second 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>
App startup performance
- Mono GitHub PR 19102: Use
GArray
instead ofGList
when getting custom attributes from an image. This reduces the number of memory allocations during app startup for a standard Xamarin.Forms app, which should improve startup times by several milliseconds.
R8 configured to suppress common build errors
Xamarin.Android now configures R8 to skip emitting an error for Java dependency warnings such as:
R8 : warning : Missing class: org.apache.http.client.methods.HttpEntityEnclosingRequestBase
R8 : warning : Missing class: java.lang.ClassValue
R8 : error : Compilation can't be completed because some library classes are missing.
This allows a more gradual transition to R8, particularly for projects that are using R8 for multidex only and not code shrinking.
Although R8 warnings will no longer cause the build to fail, project authors are encouraged to address the warnings at their earliest convenience and then set R8 back to its original stricter behavior. To restore the original behavior, set the AndroidR8IgnoreWarnings
MSBuild property to false
in the .csproj file:
<PropertyGroup>
<AndroidR8IgnoreWarnings>false</AndroidR8IgnoreWarnings>
</PropertyGroup>
Example: How to solve Missing class: org.apache.http.client
R8 : warning : Missing class: org.apache.http.client.methods.HttpEntityEnclosingRequestBase
Best solution
Update any NuGet packages or Java dependencies that use the Apache HTTP client to newer versions that use java.net.HttpURLConnection
instead. This is the best solution because starting in Android 6.0 Marshmallow (API level 23), the Apache HTTP client is deprecated in favor of the more efficient HttpURLConnection
.
Second-best solution
If new library versions are not yet available that use HttpURLConnection
, then, where possible, update any NuGet packages that use Apache HTTP client to newer versions that include a UsesLibraryAttribute
for org.apache.http.legacy:
[assembly: UsesLibrary("org.apache.http.legacy", false)]
NuGet package authors who cannot yet update all dependencies to use HttpURLConnection
are encouraged to add this attribute to their projects as soon as possible.
This attribute automatically generates the following element under the <application>
node of AndroidManifest.xml for any app that references the NuGet package:
<uses-library android:name="org.apache.http.legacy" android:required="false" />
Fallback solution
If updated NuGet package versions are not yet available with the attribute, then add the same UsesLibraryAttribute
directly to the application project instead:
[assembly: UsesLibrary("org.apache.http.legacy", false)]
Background information
The Missing class: org.apache.http.client warning indicates that the app has a Java dependency on the Apache HTTP client. Starting in Android 6.0 Marshmallow (API level 23), that client was deprecated and moved out of android.jar into its own org.apache.http.legacy.jar library. As a result, applications that use Apache HTTP client on Android 6.0 or higher will only be able to call the APIs successfully if they declare the use of org.apache.http.legacy via a <uses-library>
element in AndroidManifest.xml. Otherwise, the API calls will fail with exceptions similar to:
Java.Lang.NoClassDefFoundError: Failed resolution of: Lorg/apache/http/impl/client/DefaultHttpClient
Example: How to solve Missing class: java.lang.ClassValue
R8 : warning : Missing class: java.lang.ClassValue
Solution
It is typically safe to suppress this warning:
-
Add a new text file to the project, named for example proguard-rules.pro.
-
Set the contents of the file to:
-dontwarn java.lang.ClassValue
-
Edit the .csproj file in a text editor and add
--pg-conf proguard-rules.pro
to theAndroidR8ExtraArguments
MSBuild property, for example by adding the following lines:<PropertyGroup> <AndroidR8ExtraArguments>--pg-conf proguard-rules.pro</AndroidR8ExtraArguments> </PropertyGroup>
(If the project is configured to use R8 for code shrinking, an easier option is to set the Build Action of proguard-rules.pro to ProguardConfiguration in the Visual Studio Properties window, but that approach is not yet supported when using R8 for multidex only.)
Background information
The Missing class: java.lang.ClassValue warning indicates that the app references a library that uses java.lang.ClassValue
. Typically this happens when the app references a library that was built to run on multiple Java platforms. On Android, the java.lang.ClassValue
type does not exist in the java.lang package.
One known scenario that produces this warning is when an app references the Xamarin.Firebase.Firestore NuGet package, which depends on the cross-platform Google Guava library. Guava uses java.lang.ClassValue
, but it only uses it on platforms where it is available, so it is safe to suppress the Missing class: java.lang.ClassValue warning for that library.
A future version of the Xamarin.Guava.Google NuGet package will provide the -dontwarn java.lang.ClassValue
R8 rule to suppress the warning automatically. In the mean time, application authors can suppress the warning by adding the rule to their app projects directly.
XA1011 error for D8 with ProGuard
Any project using the D8 DEX compiler that has either Code shrinker (AndroidLinkTool
) set to ProGuard or the older AndroidEnableProguard
MSBuild property set to true
will now get an XA1011 build error:
error XA1011: Using ProGuard with the D8 DEX compiler is no longer supported. Please update `$(AndroidLinkTool)` to `r8`.
In the past, this configuration was allowed, but now only the R8 code shrinker is supported for use with the D8 DEX compiler.
To resolve this error, update the Code shrinker setting in the Visual Studio project property pages to r8. This corresponds to the r8
value for the AndroidLinkTool
MSBuild property in the .csproj file:
<PropertyGroup>
<AndroidLinkTool>r8</AndroidLinkTool>
</PropertyGroup>
Note: R8 might in some cases produce new build warnings or errors compared to ProGuard, so the ProGuard rules for the project might require updates after this change.
More aggressive incremental clean of obj directory for certain scenarios
In previous versions, Xamarin.Android reserved a costlier, more complete incremental clean of the intermediate output directory for special scenarios where a NuGet package changed or where the AndroidPackageNamingPolicy
MSBuild property changed. Xamarin.Android 10.3 expands this behavior to cover several other MSBuild properties:
- `Android...
Xamarin.Android 10.3.0.33
March 26, 2020 — Xamarin.Android 10.3.0.33 was published as part of Visual Studio 2019 version 16.6 Preview 2 and to the Preview updater channel of Visual Studio 2019 for Mac version 8.6 Preview 1
Corresponding Visual Studio 2019 Preview release notes
What's new
- Preview bindings for Android 11 Developer Preview
- Build and deployment performance
- App startup performance
- Mono Framework version update to 6.12
- Removal of AndroidExplicitCrunch feature
- Removal of keystore certificate fingerprint from build output
- Compatibility with embedded debug information
- Localized warnings and errors for builds
- Issues fixed
- Installing
- Open source
Preview bindings for Android 11 Developer Preview
This version includes preview bindings for the first 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>
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 now 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 10.0.99 (R) target framework version. Project authors are encouraged to switch to the new interface members like ITextClassifier.HintTextIsEditable
at their earliest convenience.
Build and deployment performance
- 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 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 4302: Avoid unneeded calls to
GetCustomAttribute()
during app startup for the common case where an app has no types decorated with the[JniAddNativeMethodRegistration]
attribute. Additionally, instead of using a managed method to propagate uncaught exceptions from Java, use a Java method that calls into the unmanaged Xamarin.Android runtime. These changes reduced the time to display the first screen of a small test Xamarin.Forms app from about 730 milliseconds to about 700 milliseconds for a Release configuration build on a Google Pixel 3 XL device. - Java.Interop GitHub PR 582: Remove a static array initialization from
JniRuntime
and an array iteration duringJniRuntime.JniTypeManager.GetTypeSignature()
, and leverageType.GetTypeCode()
for faster lookups of builtin types.
Mono Framework version update to 6.12
Xamarin.Android now uses the Mono 6.12 runtime and class libraries at Commit d90665a4, bringing in about 350 new commits.
Removal of AndroidExplicitCrunch feature
In previous Xamarin.Android versions, setting the AndroidExplicitCrunch
MSBuild property to true
would configure the build to crunch PNG drawable resources using a separate MSBuild task before passing them to AAPT.
This feature was never compatible with projects configured to use AAPT2 and was automatically disabled in those projects. For projects configured to use the older AAPT tool, this feature could cause builds to rerun AAPT on every build. Due to these limitations, this feature has now been removed from Xamarin.Android. The AndroidExplicitCrunch
MSBuild property is now ignored. Project authors who added this property to their .csproj files in the past can now remove it.
Removal of keystore certificate fingerprint from build output
The performance improvement that skips executing keytool -list
during the build means that the SHA-1 certificate fingerprint no longer appears in the build output. To determine certificate fingerprints in this version, follow the steps from the Finding your Keystore's Signature guide instead.
Compatibility with embedded debug information
The Mono Framework version in this Xamarin.Android version adds compatibility for reading embedded debugging information from assemblies built with Build > Advanced > Debugging information set to Embedded in the Visual Studio project property pages. This corresponds to the embedded
value for the DebugType
MSBuild property in the .csproj file:
<PropertyGroup>
<DebugType>embedded</DebugType>
</PropertyGroup>
See the symbol embedding design documentation for more information.
Localized warnings and errors for builds
Many of the warnings and errors in the Xamarin.Android build tasks now provide localized messages that match the region and language settings of the build environment.
Issues fixed
Application and library build and deployment
- Developer Community 861086: Starting in Xamarin.Android 10.1, errors similar to 'fixedsize' is incompatible with attribute ChildLayout (attr) enum prevented building projects successfully if they contained custom attribute names ending with the word Layout.
- GitHub PR 4340: ...
Xamarin.Android 10.2.100.7
March 16, 2020 — Xamarin.Android 10.2.100.7 was published as part of Visual Studio 2019 version 16.6 Preview 1
Corresponding Visual Studio 2019 Preview release notes
What's new
- Build and deployment performance
- App startup performance
- Android resource editing performance
- Mono Framework version update to 6.10
- Bindings projects now exclude private nested types
- Stream.Seek() for file streams from Android APIs
- Default Android tools versions update
- Support for Android App Bundle configuration files
- Removal of F# Resource.designer.fs file support
- Removal of .exe reference support
- CS0619 error for deprecated constant fields
- XA0122 and CS0618 warnings for deprecated Java.Interop.DoNotPackageAttribute
- Mono.Data.Sqlite SQLite version update
- Java.Interop nullable reference types compatibility
- Issues fixed
- Known issues
- Thank you
- Installing
- Open source
Build and deployment performance
- GitHub PR 3885: Adjust caching of device information during the build so it includes 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 forBuildApk
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 tostring.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 without fast deployment. - 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.
App startup performance
- GitHub PR 3958: Skip scanning for .exe files during app startup because Xamarin.Android app 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: Optimize the storage format of the per-application Java-to-managed and managed-to-Java type mappings to allow more efficient lookups. This reduced the time to display the first screen of a small test Xamarin.Forms app from about 800 milliseconds to about 790 milliseconds for a Release configuration build on a Google Pixel 3 XL device.
- Java.Interop GitHub PR 541 Add
[MethodImpl (MethodImplOptions.AggressiveInlining)]
to Java.Interop methods and properties that are called many times during Xamarin.Forms app startup. This reduced the time to display the first screen of a blank Xamarin.Forms app from about 560 milliseconds to about 540 milliseconds for a Release configuration build on a Google Pixel 3 XL device. - Java.Interop GitHub PR 555: Implement and switch to a new
JniTypeManager.GetTypeSignature()
method that returns aJniTypeSignature
instance instead of anIEnumerable<JniTypeSignature>
. This reduced the time to display the first screen of a small test Xamarin.Forms app from about 760 milliseconds to about 750 milliseconds for a Release configuration build on a Google Pixel 3 XL device. It also reduced the number of object allocations from about 9300 to about 8900. - Java.Interop GitHub PR 557: Remove unneeded calls to
IntrospectionExtensions.GetTypeInfo()
now that Java.Interop is a .NET Standard library rather than a PCL. This reduced the time to display the first screen of a small test Xamarin.Forms app from about 755 milliseconds to about 753 milliseconds for a Release configuration build on a Google Pixel 3 XL device. - Java.Interop GitHub PR 574: Skip calling
GetCustomAttribute()
in cases whereJniTypeManager.GetSimpleReference()
can be used instead.
Android resource editing performance
- GitHub PR 3674: Correct the
Inputs
for the_ManagedUpdateAndroidResgen
target so that the target is skipped as expected during incremental design-time builds.
Mono Framework version update to 6.10
Xamarin.Android now uses the Mono 6.10 runtime and class libraries at Commit fc145be9, bringing in about 500 new commits.
Bindings projects now exclude private nested types
Previously, Xamarin.Android bindings projects generated public bindings for all...
Xamarin.Android 10.2.0.100
March 23, 2020 — Xamarin.Android 10.2.0.100 was released to the Stable updater channel of Visual Studio 2019 for Mac version 8.5.
March 16, 2020 — Xamarin.Android 10.2.0.100 was released as part of Visual Studio 2019 version 16.5.
Corresponding Visual Studio 2019 release notes
What's new compared to Xamarin.Android 10.1
Important: The names for generated Java types are different in this release. Any project that explicitly uses one of the old names that starts with md5 will need to be updated by hand to account for this change. See Breaking change for generated Java type names below for more details.
Important: The default multidex tool is now R8 instead of DX. R8 performs additional Java dependency checks that can result in new build warnings and errors like:
R8 : error : Compilation can't be completed because some library classes are missing.
See D8 enabled by default for all projects below for more details
- Breaking change for generated Java type names
- D8 enabled by default for all projects
- AndroidEnableDesugar now requires D8
- Mono Framework version update to 6.8
- Build and deployment performance
- App startup performance
- Android resource editing performance
- Improved Android manifest merging
- Custom profiles for Enable Startup Tracing
- Bindings projects support for Kotlin libraries
- Android App Bundle publishing format workflow improvements
- Managed TLS 1.0 setting now uses Native TLS 1.2+
- New build errors and warnings XA0121, XA2000, XA2001
- AAPT2 version update to 3.5.0-5435860
- Mono debugger and compiler option passthroughs
- Issues fixed
- Thank you
- Installing
- Open source
Breaking change for generated Java type names
The fallback option in Xamarin.Android 10.1 that allowed using the old style of generated Java type names that started with md5 has now been removed.
Authors of projects that include literal uses of generated Java type names that start with md5 will now need to transition to alternatives like the [Register]
attribute and the [Activity]
attribute.
Projects that have the LowercaseMD5
fallback option set in the $(AndroidPackageNamingPolicy)
MSBuild property will now fail to build with the following error:
error XAGJS7015: System.NotSupportedException: PackageNamingPolicy.LowercaseHash is no longer supported.
To resolve the error, remove the section for the $(AndroidPackageNamingPolicy)
property from the .csproj file:
<PropertyGroup>
<AndroidPackageNamingPolicy>LowercaseMD5</AndroidPackageNamingPolicy>
</PropertyGroup>
See the Xamarin.Android 10.1 release notes for additional background information about this change and examples of how to update existing projects.
D8 enabled by default for all projects
Xamarin.Android has included an option to use the D8 DEX compiler since Xamarin.Android 9.2, but is has so far been disabled by default to provide a gradual path for finding and addressing compatibility issues. Starting in Xamarin.Android 10.2, the D8 DEX compiler option is now enabled by default for both existing and new projects.
To switch back from D8 to the earlier DX compiler for a particular project, set the Dex compiler option in the Visual Studio project property pages first to d8 and then to dx and save the changes, or set the $(AndroidDexTool)
MSBuild property to dx
by hand in the .csproj file:
<PropertyGroup>
<AndroidDexTool>dx</AndroidDexTool>
</PropertyGroup>
Important: Because the default DEX compiler is now D8, the default multidex tool is now R8 instead of DX. R8 performs additional Java dependency checks that can result in new build warnings and errors like:
R8 : error : Compilation can't be completed because some library classes are missing.
If needed, these errors can be suppressed temporarily by configuring R8 to be less strict:
-
Add a new text file to the project, named for example proguard-rules.pro.
-
Set the contents of the file to:
-ignorewarnings
-
Edit the .csproj file in a text editor and add
--pg-conf proguard-rules.pro
to the$(AndroidR8ExtraArguments)
MSBuild property, for example by adding the following lines:<PropertyGroup> <AndroidR8ExtraArguments>--pg-conf proguard-rules.pro</AndroidR8ExtraArguments> </PropertyGroup>
AndroidEnableDesugar now requires D8
Xamarin.Android now always use the D8 DEX compiler for projects that have the $(AndroidEnableDesugar)
MSBuild property set to true
:
<PropertyGroup>
<AndroidEnableDesugar>true</AndroidEnableDesugar>
</PropertyGroup>
Similarly, Xamarin.Android now always uses the R8 code shrinker for projects that have $(AndroidEnableDesugar)
set to true
and that have the Code shrinker ($(AndroidLinkTool)
) set to ProGuard or r8.
Note: $(AndroidEnableDesugar)
does not correspond to any setting in the project properties pages in Visual Studio, so this change only affects project authors who have added the property to .csproj files by hand.
Background information
This change allows Xamarin.Android to remove support for the old desugar_deploy.jar
mechanism from the Android Jack toolchain that was deprecated in 2017.
Mono Framework version update to 6.8
Xamarin.Android now uses the Mono 6.8 runtime and class libraries at Commit c0c5c78e, bringing in about 800 new commits.
Build and deployment performance
- GitHub PR 3692: For the specific scenario of Debug builds that have Use Fast Deployment enabled, undo part of the change from [GitHub PR 2718][github-pr-2718] so that type mappings are parsed at run time instead of being compiled into unmanaged native shared libraries. This reduced the time for the
GenerateJavaStubs
task from about 540 milliseconds to about 320 milliseconds for an incremental build of a test app where theMainActivity
type was modified between builds. As expected, this did increase the app startup time from about 1.30 seconds to about 1.35 seconds, but that still left an overall savings of approximately 170 milliseconds. - GitHub PR 3856: Add a fallback naming scheme for the files that mark whether the outputs of the
_CompileAndroidLibraryResources
target are up-to-date with the input files. This allows projects that use a google-services.json item and that are configured to use AAPT2 to skip the_CompileAndroidLibraryResources
target correctly during incremental builds. - GitHub PR 3907: Adjust
GenerateResourceDesigner
to use System.Reflection.Metadata rather than Cecil, use loops instead of LINQ expressions, and skip over .NET Standard libraries. This reduced the time for theGenerateResourceDesigner
task during an incremental build from about 470 milliseconds to about 370 milliseconds for a small app on a test system. - GitHub PR 4020: Skip a managed linker step for assemblies that have no references to
Java.Lang.Object
, such as .NET Standard libraries. This reduced the time for the_LinkAssembliesNoShrink
target on a test system from about 160 milliseconds to about 50 milliseconds for an incremental build after a one-line change to theMainActivity
class. - Mono GitHub PR 17898: Skip over unnecessary DNS lookups for the IP address of the target Android device or emulato...
Xamarin.Android 10.2.0.100 Preview
March 10, 2020 — Xamarin.Android 10.2.0.100 was published to the Preview updater channel of Visual Studio 2019 for Mac version 8.5 Preview 6.
March 2, 2020 — Xamarin.Android 10.2.0.100 was published as part of Visual Studio 2019 version 16.5 Preview 5.
Corresponding Visual Studio 2019 Preview release notes
What's new
Issues fixed
Application Mono Framework behavior on device and emulator
This version of Xamarin.Android updates the Mono 6.8 runtime and class libraries from Commit 1cca0cfe to Commit c0c5c78e, adding 14 new commits.
Fixes included for issues reported with Xamarin.Android applications:
-
Developer Community 756697: Starting in Xamarin.Android 10.0, NTLM authentication in Xamarin.Android apps no longer worked, resulting in server-side
System.ComponentModel.Win32Exception
exceptions.The initial fix for this issue in Xamarin.Android 10.1 was incomplete. Xamarin.Android 10.2 now includes additional changes that allow switching back to the Xamarin.Android 9.4
HttpClient
behavior.To switch back to the Xamarin.Android 9.4 behavior, set the
$(AndroidHttpClientHandlerType)
MSBuild property toSystem.Net.Http.MonoWebRequestHandler, System.Net.Http
in your .csproj file:<PropertyGroup> <AndroidHttpClientHandlerType>System.Net.Http.MonoWebRequestHandler, System.Net.Http</AndroidHttpClientHandlerType> </PropertyGroup>
Installing
To get the new version in Visual Studio, update Visual Studio:
- Visual Studio 2019 version 16.5 Preview 5 — Visual Studio Installer
- Visual Studio 2019 for Mac version 8.5 Preview 6 — 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
- The corresponding open-source build for this version without commercial features is xamarin-android-d16-5 build #38.
- 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/2019-10 build #122.
- 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.