Releases: dotnet/android
Xamarin.Android 9.4.0.34
Xamarin.Android 9.4.0.34 was released to the Preview updater channel of Visual Studio 2019 for Mac.
Update June 25, 2019: Xamarin.Android 9.4.0.34 is now also available as part of Visual Studio 2019 version 16.2 Preview 3.
Corresponding Visual Studio 2019 Preview release notes
What's new
Issues fixed in Xamarin.Android 9.4.0.34
Application Mono Framework behavior on device and emulator and AOT compilation
This version of Xamarin.Android updates the Mono 6.0 runtime and class libraries from Commit 3dc72cfe to Commit c6edaa62, adding 30 new commits.
Changes relevant to Xamarin.Android:
- GitHub 3120: Projects with AOT Compilation enabled would fail to build with "error XA3001: Could not AOT the assembly".
- Mono GitHub 13231: Starting in Xamarin.Android 9.4.0.17, some usage scenarios could potentially lead to a native fault due to a race condition related to marshaling a delegate to pass to unmanaged code while finalizing another delegate.
- Mono GitHub 14214: Starting in Xamarin.Android 9.4.0.17,
HttpClient.SendAsync()
could fail when attempting requests with response bodies larger than 2 gigabytes due to "Cannot write more bytes to the buffer than the configured maximum buffer size."
Application and library build process
- GitHub PR 3128, GitHub PR 3172: Building a project with Xamarin.Android 9.3 and then building the same project with Xamarin.Android 9.4 without cleaning the project between the builds would fail with "error: duplicate class: mono.MonoPackageManager_Resources ... public class MonoPackageManager_Resources {".
- GitHub PR 3146: Attempting to submit an Android App Bundle generated by setting
$(AndroidPackageFormat)
toaab
would result in a "The Android App Bundle was not signed." error on Google Play because the build process did not yet automatically sign the bundle with an algorithm that Google Play would accept. - GitHub PR 3138: Starting in Xamarin.Android 9.4.0.17, the incremental debug build times with Use Shared Runtime increased because the
GenerateJavaStubs
task was was performing additional work to generate the new style of unmanaged type mappings for the pre-built shared runtime APK. Xamarin.Android 9.4.0.34 no longer does that extra build work. Instead, the deployed applications now load the pre-built type mappings for the shared runtime APK from that APK, as they did in Xamarin.Android 9.3 and earlier. - GitHub PR 3174: Builds could fail due to "error APT0000: failed parsing overlays." for projects with Use incremental packaging system (aapt2) enabled. Xamarin.Android 9.4.0.34 updates the included
aapt2
executable to version 3.4.1-5326820 to resolve this issue. - Builds could occasionally fail during the
ResolveXamarinAndroidTools
task with "Did not find Xamarin.Android at path ... warning XA5300: Unable to determine Xamarin.Android version" due to the order in which MSBuild ran theResolveXamarinAndroidTools
task relative to theDetectIfAppWasUninstalled
task. @(AndroidAsset)
MSBuild items that used%(LogicalName)
metadata with relative paths were not copied to the correct intermediate output location during the build.
Application behavior on device and emulator
- GitHub 3169: Applications could hit an exception similar to "Failed resolution of: Landroid/support/v7/appcompat/R$drawable; ---> Java.Lang.ClassNotFoundException: Didn't find class "android.support.v7.appcompat.R$drawable" on path: DexPathList" in projects that had Use incremental packaging system (aapt2) enabled.
Known issues in Xamarin.Android 9.4.0.34
- GitHub 3168: The new
$(AndroidEnableProfiledAot)
option to enable compiling a specific subset of methods to unmanaged code is not yet ready to try on Windows in this version. The unmanaged compilation step fails on Windows with "Assertion at ... /mono/mini/aot-compiler.c:11933, condition `res == 1' not met".
OSS core
The commercial build for this version is based on the bundle from the open-source xamarin-android-d16-2 build #32.
Xamarin.Android 9.4.0.17
Xamarin.Android 9.4.0.17 was released as part of Visual Studio 2019 version 16.2 Preview 2.
Corresponding Visual Studio 2019 Preview release notes
What's new
- Build and deployment performance
- Mono Framework version update to 6.0
- Support for Android App Bundle publishing format
- App startup performance
- Preview bindings for Android Q Beta
- AAPT2 enabled by default
jit-times
analysis tool- Issues fixed
- Known issues
Build and deployment performance
- GitHub PR 2536, with follow-up adjustments in GitHub PR 2870, GitHub PR 2878, GitHub PR 2916: Add a .jar file to the Xamarin.Android installer package that contains pre-built versions of a number of Java classes that are used by every Xamarin.Android project. That way the individual projects don't need to build the Java classes themselves. This reduced the total time for the Java compilation step on a clean build of a test app from about 2.7 seconds to about 2.5 seconds.
- GitHub PR 2896: Adjust the Android resource compilation build step to avoid re-running AAPT (or AAPT2) individually for each library and to avoid generating many extra unused resource IDs. In apps that reference libraries containing many resources, such as the Xamarin.Android.Support and Xamarin.GooglePlayServices libraries, this will often dramatically decrease the total number of fields in the app. This means that those apps are now less likely to exceed the DEX 64K reference limit and less likely to require the Enable Multi-Dex setting in the Visual Studio project property pages. For example, in a test Xamarin.Forms application, the number of references in the .dex file dropped from about 30,000 to about 18,000, the .dex file size decreased from about 3.5 megabytes to about 3.4 megabytes, and the total time for the resource compilation step in a clean build dropped from approximately 3 seconds to about 20 milliseconds.
- GitHub PR 2930: Revise the
Inputs
andOutputs
for the_BuildLibraryImportsCache
target, and adjust theGetImportedLibraries
to take advantage of those adjustments. This allows incremental builds to skip the_BuildLibraryImportsCache
target when appropriate. It also improves the performance ofGetImportedLibraries
for clean builds. For example, in a test Xamarin.Forms app, this change saved approximately 100 milliseconds for an incremental build after a XAML file change, and it reduced the clean build time for theGetImportedLibraries
target from approximately 300 milliseconds to approximately 170 milliseconds in the same project. - GitHub PR 2934, with follow-up adjustments in GitHub PR 2958: Avoid running the Xamarin.Android-specific
_BuildAdditionalResourcesCache
or_ResolveLibraryProjectImports
build steps on assembly types like .NET Standard assemblies that never contain Xamarin.Android library project features such as Android resources. This reduced the incremental build time for these steps from about 360 milliseconds to about 80 milliseconds in a test Xamarin.Forms app where only the .NET Standard project was modified between builds. This also reduced the clean build time for these steps in the same project from about 1.8 seconds to about 1.2 seconds. - GitHub PR 2935: Avoid copying extra .pdb or .mdb debugging symbol files to the bin output directory in cases where the corresponding .dll assembly files themselves are not copied to the output directory. Depending on the size and number of debugging symbols for a project and the speed of the drive where the output directory is stored, this change can potentially save a noticeable amount of time. In a smaller test project built on an SSD, this change saved roughly a few dozen milliseconds for an incremental build where an assembly changed.
- GitHub PR 2952: Remove old debug logging messages from several of the build tasks. Since MSBuild prints this information automatically when building with diagnostic verbosity, these additional logging messages are no longer needed. In some cases this change can also reduce the total build time. For example, in a test app, it reduced the clean build time from roughly 25.5 seconds to about 25.0 seconds.
- GitHub PR 2956: Expand on the previous improvement from GitHub PR 2643 that allowed the
GenerateJavaStubs
task to skip over .NET Standard assemblies by now also skipping the whole parent_GenerateJavaStubs
target in cases where only .NET Standard assemblies have changed. This allowed a small test Xamarin.Forms project to skip the_GenerateJavaStubs
target successfully, saving approximately 860 milliseconds for an incremental build in the case where only a XAML file was changed.
Mono Framework version update to 6.0
This version of Xamarin.Android updates the Mono runtime and class libraries from Mono 5.18 to Mono 6.0 Commit 3dc72cfe, adding about 1,800 new commits.
Support for Android App Bundle publishing format
GitHub PR 2841, with follow-up adjustments in GitHub PR 2989: At Google I/O 2018, Android introduced a new Android App Bundle publishing format for Google Play. Xamarin.Android 9.4 includes a new build option to generate Android App Bundles for Xamarin.Android apps. To try this new output format with your project, set the $(AndroidPackageFormat)
MSBuild property to aab
in your .csproj file:
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<AndroidPackageFormat>aab</AndroidPackageFormat>
</PropertyGroup>
When this property is set, the SignAndroidPackage
MSBuild target will create an archive in the bin directory that follows the Android App Bundle format. But be aware that there is a known issue with the current preview where the build process does not yet automatically sign the bundle with an algorithm that Google Play will accept.
Known issues
-
GitHub PR 3146: Attempting to submit an Android App Bundle generated with
$(AndroidPackageFormat)
set toaab
will currently result in a "The Android App Bundle was not signed." error on Google Play. A manual workaround is to re-sign the.aab
archive by hand usingjarsigner.exe
in a command prompt, using a command similar to:"C:\Program Files\Android\jdk\microsoft_dist_openjdk_1.8.0.25\bin\jarsigner.exe" ^ -digestalg SHA-256 ^ -sigalg SHA256withRSA ^ -keystore "C:\Users\WindowsUser\com.contoso.keystore" ^ -storepass password ^ -keypass password ^ -signedjar bin\Release\com.contoso.app1-Signed.aab ^ obj\Release\90\android\bin\com.contoso.app1.aab ^ com.contoso
The last 5 lines of this example command would all need to be adjusted to match your particular keystore information and application name.
-
Setting
$(AndroidPackageFormat)
toaab
currently increases build times for the Use Fast Deployment Debug configuration setting, so it is recommended to set the new property only for the Release configuration for now.
App startup performance
- GitHub PR 2718, with follow-up adjustments in GitHub PR 3010, GitHub PR 3026: Generate unmanaged native shared libraries to provide the per-application Java-to-managed and managed-to-Java type mappings and environment settings that Xamarin.Android applications use. Previously, this information was stored in data files within the APK that the applications would load and parse during startup, but now the application can directly run the unmanaged executable instructions instead. This reduced the startup time from about 240 milliseconds to about 230 milliseconds for a Release con...
Xamarin.Android 9.3.0.22
Xamarin.Android 9.3.0.22 was released as part of Visual Studio 2019 version 16.1.
Update June 4, 2019: Xamarin.Android 9.3.0.22 is now also available in the Preview updater channel of Visual Studio 2019 for Mac.
Update June 13, 2019: Xamarin.Android 9.3.0.22 is now available in the Stable updater channel of Visual Studio 2019 for Mac.
Issues fixed
Application and library build process
- Developer Community 551186, GitHub 3045: Starting in Visual Studio 2019 version 16.1 Preview 2, projects referencing certain NuGet packages such as Microsoft.Extensions.Http would fail to build with an error similar to "FileNotFoundException: Could not load assembly 'System.Runtime..." during the
LinkAssemblies
task.
Application behavior on device and emulator
- GitHub PR 3009: Apps built with multidex and either the ProGuard or R8 code shrinker enabled could fail during startup with "java.lang.ClassNotFoundException: Didn't find class "android.support.multidex.MultiDexApplication"" unless a rule was explicitly added to the ProGuard configuration file to preserve the class. Xamarin.Android 9.3 now includes an appropriate ProGuard configuration rule by default, so the rule no longer needs to be added by hand.
Application Mono Framework behavior on device and emulator
This version of Xamarin.Android updates the Mono 5.18 runtime and class libraries from Commit 3f5ec6d9 to Commit 3cb36842, adding 5 new commits.
In this particular case, none of the new commits are expected to be relevant to Xamarin.Android projects. The changes are included to keep the Mono commit aligned with the desktop Mono Framework MDK and Xamarin.iOS.
OSS core
The commercial build for this version is based on the bundle from the open-source xamarin-android-d16-1 build #28.
Xamarin.Android 9.3.0.19
Xamarin.Android 9.3.0.19 was released as part of Visual Studio 2019 version 16.1 Preview 3 and to the Preview updater channel of Visual Studio 2019 for Mac.
Issues fixed
Application Mono Framework behavior on device and emulator
This version of Xamarin.Android updates the Mono 5.18 runtime and class libraries from Commit bf4e8d2a to Commit 3f5ec6d9, adding 1 new commit:
- Mono GitHub 13878: For Xamarin.Mac, certain JIT features were not yet compatible with new macOS security features. This commit is not important for Xamarin.Android itself. It is included in this release to keep the Mono commit aligned with Xamarin.Mac and Xamarin.iOS.
Design-time build process
- GitHub PR 2991: Starting in Visual Studio 2019 version 16.1 Preview 2, design-time features such as IntelliSense could fail in certain cases if a referenced library included an empty Android resources directory.
Xamarin.Android SDK installation
- GitHub PR 2959: Starting in Visual Studio 2019 version 16.1 Preview 2, Xamarin.Android included a number of unneeded temporary files left over from the installer package build process. The installer package for Xamarin.Android 9.3.0.19 no longer includes those unneeded files.
OSS core
The commercial build for this version is based on the bundle from the open-source xamarin-android-d16-1 build #25.
Xamarin.Android 9.2.3.0
Xamarin.Android 9.2.3.0 was released to the Stable updater channel of Visual Studio 2019 for Mac.
Update April 30, 2019: Xamarin.Android 9.2.3.0 is now also available as part of Visual Studio 2019 version 16.0.3. The difference in publication date was due to a few coincidences with the timing of this particular release.
Issues fixed
Application Mono Framework behavior on device and emulator
This version of Xamarin.Android updates the Mono 5.18 runtime and class libraries from Commit 5ad371da to Commit 5ac37ccd, adding 2 new commits:
- Developer Community 435502, Developer Community 515603, GitHub 2920: Xamarin.Android apps would crash during debugging when they called certain APIs. Applications affected by this issue would run successfully if launched without the debugger attached, but when launched with the debugger attached, the applications would exit unexpectedly after one of the problematic APIs was called. The debug output would show a "Fatal signal 11 (SIGSEGV)" after the crash.
- Mono GitHub 13610: Xamarin.Android projects in which users had explicitly set a value for the undocumented, experimental
$(AndroidAotMode)
MSBuild property could hit a problem where methods that returnedTask
objects or generic types would lead to incorrect return values. This is not expected to be an issue for any current Xamarin.Android projects. The fix is included in this release to keep the Mono commit aligned with Xamarin.iOS.
OSS core
The commercial build for this version is based on the bundle from the open-source xamarin-android-d16-0 build #36.
Xamarin.Android 9.3.0.14
Xamarin.Android 9.3.0.14 was released as part of Visual Studio 2019 version 16.1 Preview 2 and Visual Studio 2019 for Mac.
What's new
- Build and deployment performance
- App startup performance
- Android NDK r19 compatibility
- Easier way to use
android:extractNativeLibs="false"
- arm64-v8a architecture enabled by default
- R8 version update to 1.3.52
- Mono.Data.Sqlite SQLite version update
- OpenTK version 0.9.9.3 warning
- Issues fixed
Build and deployment performance
- GitHub PR 2554: Skip the
_SetLatestTargetFrameworkVersionForPackageReference
MSBuild during NuGet restore unless$(AndroidUseLatestPlatformSdk)
istrue
. This saved roughly 600 milliseconds for NuGet restore on a test project that used an explicit$(TargetFrameworkVersion)
with$(AndroidUseLatestPlatformSdk)
set tofalse
. - GitHub PR 2561: Remove the old
_RegisterAndroidFilesWithFileWrites
target that is no longer needed. This trimmed about 80 milliseconds off the build time of a test project. - Java.Interop GitHub PR 405, GitHub PR 2576: Change some LINQ expressions to loops and remove some redundant assembly metadata retrieval steps. This reduced the time for the
GenerateJavaStubs
task in a test project from approximately 1414 milliseconds to 1355 milliseconds. - GitHub PR 2589: Change a few uses of temporary on-disk files to work all in memory instead.
- GitHub PR 2612: Switch the
ResolveAssemblies
task to use System.Reflection.Metadata instead of Mono.Cecil. This reduced the time for theResolveAssemblies
task in a test project from about 320 milliseconds to about 110 milliseconds. - GitHub PR 2624: Switch the
GetAdditionalResourcesFromAssemblies
task to use System.Reflection.Metadata instead of Mono.Cecil. This reduced the time for theGetAdditionalResourcesFromAssemblies
task in a test project from about 100 milliseconds to about 50 milliseconds. - GitHub PR 2626: Exclude the
Build
target from being a dependency of theSignAndroidPackage
when building inside the IDE. This reduced the time to re-launch an unchanged test application from roughly 6.5 seconds to roughly 4.5 seconds. - GitHub PR 2643: Skip over .NET Standard (and Portable Class Library) projects in the
GenerateJavaStubs
task because those project types never need to interact with Java. This reduced the total time for theGenerateJavaStubs
task from about 1 second to 870 milliseconds for incremental builds of a test Xamarin.Forms project. Projects that use more .NET Standard libraries could see a more noticeable time savings.
App startup performance
Java.Interop GitHub PR 416, GitHub PR 2716: Change the JNI runtime interop initialization to happen lazily, allowing the app to skip some parts during startup. This reduced the time for this initialization step from roughly 225 milliseconds to 216 milliseconds for a test application on a Pixel 2 XL device.
Android NDK r19 compatibility
Xamarin.Android version 9.3 adds compatibility for running clang
rather than gcc
for the Bundle assemblies into native code and AOT Compilation build options. This allows Xamarin.Android to use Android NDK version r18 and above, where GCC has been removed.
The native libraries that are part of Xamarin.Android are now also built against Android NDK r19. The updated Android NDK toolchain means that it is now recommended to use Xamarin.Android apps only with devices running Android 4.1 (API level 16) or higher. Warning XA4216 has been updated accordingly to help highlight this change for any projects that might still have an older version set for the minSdkVersion
in the AndroidManifest.xml file.
Easier way to use android:extractNativeLibs="false"
Xamarin.Android 9.2 added support for the android:extractNativeLibs="false"
setting, but enabling it required several manual steps. Xamarin.Android 9.3, makes this feature easier to work with by trimming down the number of steps to just one:
- Add the
android:extractNativeLibs="false"
attribute to the<application/>
element in the Properties\AndroidManifest.xml file
arm64-v8a architecture enabled by default
Starting August 1, 2019, Google Play will require all new apps and app updates that include native code to provide 64-bit versions in addition to 32-bit versions. To align with this upcoming requirement, Xamarin.Android version 9.3 now includes both armeabi-v7a and arm64-v8a in the default value of the $(AndroidSupportedAbis)
MSBuild property. This change will only affect existing build configurations if the property is blank for that configuration in the .csproj file. The change will not affect build customized configurations where the property already includes an architecture other than armeabi-v7a.
R8 version update to 1.3.52
The version of the R8 code shrinker included in Xamarin.Android has been updated from 1.2.52 to 1.3.52.
Mono.Data.Sqlite SQLite version update
The version of SQLite used by Mono.Data.Sqlite in Xamarin.Android has been updated from 3.26.0 to 3.27.1, bringing in several improvements and bug fixes.
OpenTK version 0.9.9.3 warning
As mentioned in the previous release notes, the assembly for OpenTK version 0.9.9.3 will be removed from Xamarin.Android in an upcoming release. To help prepare for this removal, Xamarin.Android 9.3 now provides a build warning for any project referencing OpenTK version 0.9.9.3:
warning XA1009: OpenTK 0.9.3 is Obsolete. Please upgrade to OpenTK 1.0
To resolve this warning in Visual Studio, ensure the selected reference for OpenTK is:
And in Visual Studio for Mac, ensure the selected reference is:
Issues fixed
Application and library build process
- Developer Community 330758: Projects that had indirect dependencies on version 4.3.0 of the System.Runtime.Loader NuGet package would fail to build with "XA0009: Error while loading assembly ... BadImageFormatException". Xamarin.Android 9.3 allows these projects to build without error. As a caution, the
System.Runtime.Loader.AssemblyLoadContext
class in Xamarin.Android currently only provides empty implementations, so although certain APIs from NuGet packages that depend on the System.Runtime.Loader NuGet package will work already, features that specifically depend onAssemblyLoadContext
will encounterNotImplementedException
errors. - Developer Community 346386: Attempting to cancel a build during the AOT Compilation step would only stop the build after the AOT step completed. In Xamarin.Android 9.3, canceling the build during the AOT step now aborts the step as expected.
- Developer Community 514955: Starting in Visual Studio 2019 for Mac, the References list in the Solution pad and the Edit References window showed error icons and missing entries for most of the base class libraries in Xamarin.Android projects.
- GitHub 1768: The build process did not yet provide warnings to guide projects toward the recommended best practice of keeping
minSdkVersion
less than or equal totargetSdkVersion
andtargetSdkVersion
equal tocompileSdkVersion
. - [GitHub PR 2349](https://github.com/xamarin/xamarin-android/pull/...
Xamarin.Android 9.2.0.5
Xamarin.Android 9.2.0.5 was released as part of Visual Studio 2019 RC.3 and Visual Studio 2019 Preview 4.3.
Issues Fixed
Design-Time Build Process
- GitHub PR 2803: The Xamarin.Forms previewer could show a blank page labeled "AndroidFormsPreviewerRenderer" for XAML files in certain projects until the projects were built. The previewer can now render the XAML files in those projects successfully without requiring the projects to be built.
Xamarin.Android 9.2.0.4
Xamarin.Android 9.2.0.4 was released as part of Visual Studio 2019 RC.2 and Visual Studio 2019 Preview 4.2.
Issues Fixed
Application Behavior on Device and Emulator
- Developer Community 442312, GitHub 2679: Attempting to call
new X509Certificate(bytes)
could fail with "System.PlatformNotSupportedException: Cannot get `ISystemDependencyProvider`." on device or emulator.
Xamarin.Android 9.2.0.3
Xamarin.Android 9.2.0.3 was released to the Xamarin Preview updater channel of Visual Studio 2019 for Mac Preview.
Issues Fixed
Application Mono Framework Behavior on Device and Emulator
This version of Xamarin.Android updates the Mono 5.18 runtime and class libraries from Commit 163f45d8 to Commit 5ad371da, adding 1 new commit:
- GitHub PR 13106: Make System.dll internals visible to
Mono.Android
. This is a first step toward resolving the known issue GitHub 2679. Note that the issue is not yet resolved in Xamarin.Android 9.2.0.3 because the corresponding change to take advantage of the new visibility of the System.dll internals is not yet in place.
Known Issues
-
GitHub 2679: Attempting to call
new X509Certificate(bytes)
can fail with "System.PlatformNotSupportedException: Cannot get `ISystemDependencyProvider`." on device or emulator. This issue depends on the order of type instantiations and method calls.Workaround: Invoke the non-public
Mono.SystemDependencyProvider.Initialize()
method at some point in your app before the first use ofX509Certificate
. One option is to use reflection to locate and invoke the method:var t = Type.GetType("Mono.SystemDependencyProvider, System", throwOnError: true); var m = t.GetMethod("Initialize", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static); m.Invoke(null, null);
Another approach is to use some part of the public API surface that invokes the method behind the scenes. For example, the following line is sufficient:
new X509Certificate2(new X509Certificate());
Xamarin.Android 9.2.0.1
Xamarin.Android 9.2.0.1 was released as part of Visual Studio 2019 RC and Visual Studio 2019 Preview 4.
Issues Fixed
Application and Library Build Process
-
Developer Community 437807, GitHub 2685: Starting in the earlier Visual Studio 2019 Previews, builds could fail with "error MSB6006: "java.exe" exited with code 1." if project paths contained non-ASCII characters.
-
GitHub 2652: Starting in the earlier Visual Studio 2019 Previews, projects with AOT enabled would fail to build with "error XA5101: Missing Android NDK toolchains directory" unless the project also explicitly set the NDK path via the
$(AndroidNdkDirectory)
MSBuild property. Now the build will automatically locate the NDK if it is present in the ndk-bundle subdirectory of the Android SDK directory. -
GitHub 2692: The build tasks and targets did not yet provide a warning for projects that have the minimum Android version set lower than Android 2.3 (API level 9). This warning is needed because the native parts of Xamarin.Android are built against Android NDK r14, so Xamarin.Android apps might not work correctly on devices running Android versions older than Android 2.3 (API level 9).
-
GitHub 2708: Starting in the earlier Visual Studio 2019 Previews, projects that used either Bundle assemblies into native code or AOT Compilation (Experimental) and did not explicitly set the NDK path via the
$(AndroidNdkDirectory)
MSBuild property would fail to build with two different error messages, neither of which mentioned how to resolve the error. Both scenarios now produce the same error, and the error mentions how to resolve the error by installing the NDK or setting the MSBuild property. -
GitHub PR 2724: Starting in Visual Studio 2019 Preview 3, apps could encounter exceptions if they used
AppDomain.GetAssemblies()
. Xamarin.Forms apps that used CSS style sheets and did not have XAML Compilation enabled were one example. In Xamarin.Android 9.2.0.1, these apps will once again automatically preload all assemblies during startup, preventing the exceptions. Note that preloading the assemblies does increase startup time. Future versions of Xamarin.Forms will no longer require the preload step for any scenarios. If your app is already compatible with skipping the preload step, you can re-enable the performance improvement by setting the$(AndroidEnablePreloadAssemblies)
MSBuild property tofalse
in your .csproj file:<PropertyGroup> <AndroidEnablePreloadAssemblies>false</AndroidEnablePreloadAssemblies> </PropertyGroup>
Application Mono Framework Behavior on Device and Emulator
This version of Xamarin.Android updates the Mono 5.18 runtime and class libraries from Commit 725ba2a2 to Commit 163f45d8, adding 10 new commits.
A few improvements and issues fixed relevant to Xamarin.Android are:
- GitHub PR 12058: Disable probing the AOT cache on Android, where it is unnecessary. This saves time during application startup.
- GitHub 12538: Applications could sometimes hit an exception during startup due to a race condition.
- GitHub 12688:
StackTrace.GetFrames()
was returning redundant additional frames for async methods.
Known Issues
-
GitHub 2679: Attempting to call
new X509Certificate(bytes)
can fail with "System.PlatformNotSupportedException: Cannot get `ISystemDependencyProvider`." on device or emulator. This issue depends on the order of type instantiations and method calls.Workaround: Invoke the non-public
Mono.SystemDependencyProvider.Initialize()
method at some point in your app before the first use ofX509Certificate
. One option is to use reflection to locate and invoke the method:var t = Type.GetType("Mono.SystemDependencyProvider, System", throwOnError: true); var m = t.GetMethod("Initialize", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static); m.Invoke(null, null);
Another approach is to use some part of the public API surface that invokes the method behind the scenes. For example, the following line is sufficient:
new X509Certificate2(new X509Certificate());