Xamarin.Android 10.2.100.7
Pre-releaseMarch 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 nested Java types, even when the types had private or package-private visibility. Bindings projects now respect private visibilities on nested types and no longer generate bindings for those types.
Note: This change in behavior can result in new C# compiler errors for bindings projects, such as:
error CS0426: The type name 'AttribOp' does not exist in the type 'CSSParser'
error CS0115: 'MapControllerOld.HalfCosinusalDeceleratingAnimationRunner.JniPeerMembers': no suitable method found to override
To restore any needed missing types, adjust the visibilities by adding rules like the following to the Transforms\Metadata.xml file:
<attr path="/api/package[@name='com.caverock.androidsvg']/class[@name='CSSParser.AttribOp']" name="visibility">public</attr>
<attr path="/api/package[@name='org.osmdroid.views']/class[@name='MapControllerOld.CosinusalBasedAnimationRunner']" name="visibility">public</attr>
Stream.Seek() for file streams from Android APIs
Until now, Stream.Seek()
and related properties like Stream.Position
always threw NotSupportedException
on Stream
instances returned from Android API methods. In Xamarin.Android 10.3, Stream.Seek()
and the other related properties are now available on these Stream
instances if the underlying Java types inherit from FileInputStream
.
Default Android tools versions update
The default Android SDK Build-Tools version has been updated from 28.0.3 to 29.0.2. This version can be changed per-project if needed via the AndroidSdkBuildToolsVersion
MSBuild property.
The default Android SDK Platform-Tools version has been updated from 28.0.0 to 29.0.5. This version can be changed per-project if needed via the AndroidSdkPlatformToolsVersion
MSBuild property.
Support for Android App Bundle configuration files
The Android App Bundle publishing format includes an option to customize certain details about how APKs are generated from the bundle, such as whether or not a separate configuration APK is generated for each set of language resources, screen density resources, and ABI libraries. See the documentation about BundleConfig.json files to learn more. Xamarin.Android now includes an option to pass this kind of configuration file to bundletool
during the build process.
To specify a configuration file, set the AndroidBundleConfigurationFile
MSBuild property to the path of the file. For example, add lines similar to the following to the .csproj file:
<PropertyGroup>
<AndroidBundleConfigurationFile>BundleConfig.json</AndroidBundleConfigurationFile>
</PropertyGroup>
Note: Xamarin.Android configures some of the configuration settings automatically, including the list of file extensions to leave uncompressed.
Removal of F# Resource.designer.fs file support
F# Xamarin.Android projects now generate Resource.designer.cs files instead of Resource.designer.fs files. The recommended way to consume these files is to the install the Xamarin.Android.FSharp.ResourceProvider NuGet package, which surfaces F# types for the content in the .cs file.
See the DisplayPlatformInfo sample for an example of how to use Xamarin.Android.FSharp.ResourceProvider.
Note: Xamarin.Android.FSharp.ResourceProvider does not support Resource.designer.cs files located in the intermediate output directory, so generation of resource designer files in the intermediate output directory is now disabled for F# projects.
Removal of .exe reference support
To improve performance, Xamarin.Android no longer probes for .exe files during app startup.
Projects must now use .dll assemblies for all dependencies. Compatible options include .NET Standard libraries, Xamarin.Android class libraries, Xamarin.Android binding libraries, shared projects, and portable class libraries.
The Xamarin.Android build process has historically used .dll files by default, so this change should only affect dependencies built using other project types or custom build targets.
Background info
As far back as Xamarin.Android 9.4, the Xamarin.Android build process already skipped over .exe files when packaging APKs, so this new Xamarin.Android 10.3 behavior at run time is unlikely to affect app behavior for project authors upgrading from Xamarin.Android 9.4 or above.
CS0619 error for deprecated constant fields
Certain deprecated constant fields in the Android API bindings have been updated from [Obsolete]
to [Obsolete(error:true)]
. These types will now produce CS0619 errors instead of CS0618 warnings.
To resolve these errors, switch to the types mentioned in the error messages. For example, for Android.Content.ComponentCallbacks2.TrimMemoryBackground
, the error message is:
error CS0619: 'ComponentCallbacks2.TrimMemoryBackground' is obsolete: 'This constant will be removed in the future version. Use Android.Content.TrimMemory enum directly instead of this field.'
To resolve this example error, switch the type to Android.Content.TrimMemory.Background
.
XA0122 and CS0618 warnings for deprecated Java.Interop.DoNotPackageAttribute
Any app project that references a Xamarin.Android bindings library containing uses of Java.Interop.DoNotPackageAttribute
will now get a XA0122 build warning:
warning XA0122: Assembly 'Library1' is using a deprecated attribute '[assembly: Java.Interop.DoNotPackageAttribute]'. Use a newer version of this NuGet package or notify the library author.
Similarly, any library project that includes a use of [assembly: Java.Interop.DoNotPackageAttribute]
will now get a CS0618 build warning:
warning CS0618: 'DoNotPackageAttribute' is obsolete: 'This attribute is deprecated and will be removed in a future release. Use the @(AndroidExternalJavaLibrary) MSBuild item group instead.'
Java.Interop.DoNotPackageAttribute
will be removed in a future release. Library project authors are encouraged to transition away from it at their earliest convenience, and app project authors are encouraged to update to the new library versions when they become available.
Mono.Data.Sqlite SQLite version update
The version of SQLite used by Mono.Data.Sqlite in Xamarin.Android has been updated from 3.28.0 to 3.31.1, bringing in security fixes, improvements, and bug fixes.
Java.Interop nullable reference types compatibility
The Java.Interop assembly has been updated for compatibility with C# 8.0 nullable reference type checks. Any projects that are using types directly from the Java.Interop assembly can now optionally place that code in a nullable context to take advantage of additional compiler nullability checks. Most Xamarin.Android projects only use the Java.Interop assembly indirectly, so this change is not relevant for most projects.
Issues fixed in Xamarin.Android 10.2.100.7
Application and library build and deployment
- Developer Community 888836: ADB1000: Deployment failed System.ArgumentOutOfRangeException ... Parameter name: length could prevent successful deployment on certain devices.
- Developer Community 917114: error MSB4018: The "CreateManagedLibraryResourceArchive" task failed unexpectedly ... System.ArgumentOutOfRangeException: startIndex cannot be larger than length of string. caused builds to abort for Xamarin.Android class library projects that included
AndroidAsset
items with paths outside of the project directory. - GitHub 2654: Directory obj\Release\android\assets contains *.dll but no debug symbols file was found. warnings were shown by default in Release configuration builds for apps that referenced libraries without debug symbols. These warnings were often caused by NuGet packages and so could not be resolved by app project authors. These warnings have been downgraded to informational messages for now.
- GitHub 3636: Error inflating class android.support.v7.widget.FitWindowsLinearLayout ---> Java.Lang.ClassNotFoundException: Didn't find class "android.support.v7.widget.FitWindowsLinearLayout" and similar errors could prevent apps built with Code shrinker set to ProGuard or r8 from running successfully unless custom ProGuard rules were added to the project by hand. In Xamarin.Android 10.3, projects configured to use AAPT2 now pass the
--proguard
option to AAPT2 to generate default ProGuard rules that more closely match the defaults for Android Studio projects, removing the need to add custom rules for common scenarios like theFitWindowsLinearLayout
type from the Android Support Library. - GitHub 3813: Xamarin.Android did not yet support Android App Bundle configuration files.
- GitHub PR 4149: The managed linker did not yet consider the
Java.Interop.GenericMarshaler
namespace for linking when set to link SDK assemblies only. - GitHub PR 4214: The
ConvertResourcesCases
task could leave behind a file in the user's temporary directory after the build.
Bindings projects
- GitHub PR 4385: You have Jar libraries, lint.jar, lint.jar, ... that have the identical name with inconsistent file contents build error could prevent apps from consuming custom bindings libraries for certain Java libraries. This was discovered while preparing new versions of the Xamarin.AndroidX bindings libraries.
- Java.Interop GitHub 519: error CS1001: Identifier expected caused bindings projects to fail to build for Java libraries that defined any classes outside of a Java package.
- Java.Interop GitHub 565: error CS0103: The name 'p0' does not exist in the current context caused bindings projects to fail to build for Java libraries that contained explicit interface property implementations.
- Java.Interop GitHub 571: Kotlin: Hiding internal ... method resulted in missing bindings for public Kotlin methods in cases where the method names were the same as the names of private properties or fields.
- Java.Interop GitHub 572: Package-private nested types were not automatically excluded from bindings, resulting in errors similar to error: ... is not public in ...; cannot be accessed from outside package when attempting to use the bindings.
Application behavior on device and emulator
- GitHub 4110: Unable to get provider mono.MonoRuntimeProvider_1: java.lang.ClassNotFoundException prevented apps containing broadcast receivers from launching successfully if they were built with ProGuard or R8 enabled.
Design-time build
- GitHub 2413: The
_ManagedUpdateAndroidResgen
target was running during every incremental design-time build.
Known issues
-
GitHub 4415: Cannot create instance of type ... no Java peer type found causes certain apps to crash during launch after incremental deployments.
Temporary workaround: Clean the project between deployments.
Thank you
A big Thank You! to community members who contributed improvements in this
release:
- Andrey Kurdyumov (@kant2002), GitHub PR 3848: Use HTTPS protocol instead of Git protocol for xamarin-android repository submodules that were using the Git protocol.
- @mathieubourgeois, GitHub PR 3915: Add support for Android App Bundle configuration files.
- Bruno Garcia (@bruno-garcia), GitHub PR 4004: Remove an unused libzip dependency from the xamarin-android source build.
- giga bokuchava (@mister-giga), GitHub PR 4120: Experiment with providing an implicit operator to allow assigning
Android.Graphics.Color
instances fromint
literals. - Christopher Atlan (@catlan), GitHub PR 4197: Add implementations of
Stream.Seek()
and other related properties forStream
instances from Android APIs where the original Java return types inherit fromFileInputStream
.
Installing
To get the new version in Visual Studio, update Visual Studio:
- Visual Studio 2019 version 16.6 Preview 1 — Visual Studio Installer
For other scenarios, the latest commercial .vsix 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/2019-12 build #82.
- 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.