Xamarin.Android 12.0 Release Notes
| GitHub | Developer Community | System requirements | Blogs |
Installing
Xamarin.Android 12.0 releases are distributed as part of Visual Studio 2019 16.11.
- Visual Studio 2019 version 16.11 — Visual Studio Installer (release notes)
- Visual Studio 2019 for Mac — Visual Studio for Mac Installer (release notes)
What's new in Xamarin.Android 12.0
Xamarin.Android 12.0 releases
- Xamarin.Android 12.0.0.3 in Visual Studio 2019 version 16.11.6
Xamarin.Android version 12.0.0.3
Released November 9, 2021, included in Visual Studio 2019 version 16.11.6.
- Support Android 12
- Miscellaneous
- Mono.Android
- monodroid
- .NET 6 Changes
- Optimizations
- Xamarin.Android.Build.Tasks
Support Android 12
Android 12 adds a number of new APIs in
API-31, which are now available when
$(TargetFrameworkVersion)
=v12.0.
There is unfortunate related fallout: API-31 requires JDK-11, and using JDK-11 with Visual Studio 2019 is problematic; in particular, using JDK-11 will break the Android Designer. If Android 12/API-31 must be used with Visual Studio 2019, please keep in mind that tradeoffs are involved.
Android 12/API-31 support is improved in Visual Studio 2022 and Xamarin.Android 12.1.
API diffs between $(TargetFrameworkVersion)
=v11.0 and $(TargetFrameworkVersion)
=v12.0.
Miscellaneous
Bump SQLite to v3.36.0
(PR #6038, Commit 16a81b41)Bump to r8 2.2.64
(PR #6149, Commit 736ae112)Bump to bundletool 1.8.1
(#1414786, #6354, PR #6358, Commit f686d634)dotnet build -c Release -t:Install
fails on an API-31 emulator with:[BT : 1.4.0] error : Error retrieving device density. Please try again.
Updating
bundletool
with the fix:Android12 emulator fails due to 'Error retrieving device density'
Add support for NDK r23.
(PR #6073, Commit f361d997)
Mono.Android
Obsolete
[LinkerSafe]
(#5639, PR #6054, Commit 688e2e17)Fix
WeakGlobalReferenceCount
(PR #6082, Commit fe98deea)Obsolete
[Preserve]
(#5664, PR #6129, Commit e6048334)The .NET 5+ replacement for
Android.Runtime.PreserveAttribute
isSystem.Diagnostics.CodeAnalysis.DynamicDependencyAttribute
.API-31 stabilization
(PR #6174, Commit e7228252)
monodroid
Use more standard C++ features, performance improvements
(PR #6159, Commit 28668322)Pre-allocate buffers for embedded assembly names
(PR #6188, Commit 69289d78)Fix possible
SIGSEGV
by attaching threads before asking for current domain
(#6211, PR #6223, Commit bfa8eabd)
Optimizations
- Replace
new T[0]
withArray.Empty<T>()
to reduce allocations.
(PR #6162, Commit 550325af)
Xamarin.Android.Build.Tasks
Fix
ArgumentException
in<GenerateCompressedAssembliesNativeSourceFiles/>
(PR #6032, Commit fc74854b)dotnet/maui is hitting a build error, such as:
error XAGCANSF7004: System.ArgumentException: An entry with the same key already exists. error XAGCANSF7004: at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource) error XAGCANSF7004: at System.Collections.Generic.TreeSet`1.AddIfNotPresent(T item) error XAGCANSF7004: at System.Collections.Generic.SortedDictionary`2.Add(TKey key, TValue value) error XAGCANSF7004: at Xamarin.Android.Tasks.GenerateCompressedAssembliesNativeSourceFiles.GenerateCompressedAssemblySources() error XAGCANSF7004: at Xamarin.Android.Tasks.GenerateCompressedAssembliesNativeSourceFiles.RunTask() error XAGCANSF7004: at Microsoft.Android.Build.Tasks.AndroidTask.Execute() in /Users/builder/azdo/_work/1/s/xamarin-android/external/xamarin-android-tools/src/Microsoft.Android.Build.BaseTasks/AndroidTask.cs:line 17
Reviewing the
<GenerateCompressedAssembliesNativeSourceFiles/>
MSBuild task, it appears theContainsKey()
check is not using the correct key for the dictionary.Add OpenTK/NUnitLite Error for .net 6
(PR #6031, Commit 1fb3c82c)Add support for
android:useEmbeddedDex
(Issue ##5925, PR #6042, Commit 6b87c5b6)When
//application/@android:useEmbeddedDex
is true, storeclasses.dex
within the.apk
, instead of adding it as compressed data. This prevents installation errors such as:Failure [INSTALL_FAILED_INVALID_APK: Some dex are not uncompressed and aligned correctly
Fix Assembly Ordering in
PackageManager
(PR #6057, Commit d80c9b14).NET 6 builds fail on Apple M1
(#6091, PR #6092, Commit 7dacdd75)Fix
NullReferenceException
in Xamarin.Android.Common.targets
(#6124, PR #6126, Commit 27e91bb4)Fix XA0031 message
(PR #6225, Commit 95584415)Improve XA0031 error message
(PR #6252, Commit 658db25e)update built-in AOT profiles
(PR #6247, Commit e9a4c9f9)Fix default
$(LintToolPath)
(PR #6293, Commit 4364b4ca)don't add
exported="true"
if already present
(#6284, PR #6290, Commit 9f2d3bfa)
.NET 6 Changes
Don't export the
XA_TLS_PROVIDER
envvar
(#6140, PR #6182, Commit 4b72d315)Set
$(EnableSingleFileAnalyzer)
=True by default
(#5943, PR #5989, Commit d644609b)*.runtimeconfig.json
support
(PR #6009, Commit a022f5df)Normalize case for
$(TargetPlatformIdentifier)
(PR #6025, Commit 15f23105)Set env var automatically for
$(UseInterpreter)
(#6016, PR #6027, Commit ee492495)Fixes for
System.*
@(PackageReference)
s
(PR #6043, Commit 16c3bb7f)Fixes an
XABLD7024
via anIOException
while trying to accessSystem.*
files.Enable support for
AssemblyLoadContext
(PR #5940, Commit b7224e5a)Remove as much
AppDomain
use as possible
(PR #6071, Commit 7282da94)Make
dotnet workload install android
anddotnet workload install android-aot
work
(PR #6045, Commit 600e993d)Update .NET 6 defaults for bindings projects
(#4657, PR #6066, Commit d60e7176)With .NET 6 we want to turn on the following binding project enhancements added with C# 8 by default:
- Interface constants: xamarin/java.interop@a3b74568
- Interface static methods: xamarin/java.interop@855b7e92
- Interface default methods: xamarin/java.interop@29f97075
- Interface nested types: xamarin/java.interop@28b1fc97
- Nullable Reference Types: xamarin/java.interop@01d06845
We have improvements on the initial implementation of these features; however, they break API incompatibility with existing bindings.
Add the following MSBuild properties:
$(AndroidBoundInterfacesContainConstants)
: Controls whether constants on interfaces will be supported, or the old approach of creating aIMyInterfaceConsts
class will be used.$(AndroidBoundInterfacesContainTypes)
: Controls whether types nested in interfaces will be supported, or the old approach of creating a non-nested type likeIMyInterfaceMyNestedClass
.$(AndroidBoundInterfacesContainStaticAndDefaultInterfaceMethods)
: Controls whether default and static members on interfaces will be supported, or the old workaround of creating a sibling class containing static members likeabstract class MyInterface
.
For .NET 6, the above properties all default to
true
if not explicitly set by the user.Use new API for exception debugger notification
(PR #6106, Commit e4debf72)AOT support
(#6052, PR #5539, Commit c929289a)$(AndroidClientHandler)
usage causes runtime crash:Use of folder names like
Build AndÜmläüts
fails:Implement
$(SupportedPlatformOSVersion)
forminSdkVersion
(PR #6111, Commit a66013b5).NET 6 projects don't *need() to contain
<uses-sdk/>
withinAndroidManifest.xml
:<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="30" />
Instead, the
$(SupportedPlatformOSVersion)
MSBuild property will be used to specify//uses-sdk/@android:minSdkVersion
, and$(TargetFramework)
will be used to specify//uses-sdk/@android:targetSdkVersion
.A project can still use
<uses-sdk/>
withinAndroidManifest.xml
, in which case it will override any default values from$(SupportedPlatformOSVersion)
and$(TargetFramework)
.Add missing API documentation
(PR #6155, Commit 60efd75d)Support
$(EnableLLVM)
with AOT
(PR #6157, Commit 75a0743e)$(UseSystemResourceKeys)
=true only when linking
(#6185, PR #6186, Commit df9e04dd)Add
$(AndroidGenerateResourceDesigner)
property
(#6198, PR #6224, Commit 02c33474)The new
$(AndroidGenerateResourceDesigner)
MSBuild property can be used to prevent generation ofResource.designer.cs
within .NET 6+ projects. Alternatively, the$(AndroidResgenFile)
MSBuild property can be removed, when Classic Xamarin.Android is used.This may be useful to fix errors similar to:
error CS0101: The namespace 'MyBinding' already contains a definition for 'Resource'
Use latest C# 10 language features in default templates
(#6075, #6076, PR #6118, Commit 7fb7c814)Fix
[Export]
for Release builds
(PR #6235, Commit 84608670)Release builds emit both
.apk
and.aab
App Bundles by default
(#6059, PR #6087, Commit f9f879c7)Support consuming AOT profiles
(#6053, PR #6171, Commit 3e699d6f)Fix remaining
Mono.Android.Export
linker warning
(PR #6216, Commit 8eb10dd4)Specify platforms for
android
andandroid-aot
workloads
(PR #6276, Commit 6009ed67)Fix binding generation for
.jar
in application projects
(PR #6281, Commit 58c8d5ec)Rework
$(ApplicationVersion)
and$(ApplicationDisplayVersion)
(PR #6139, Commit da5b904e)To be more consistent with other platforms, we now define:
$(ApplicationVersion)
->android:versionCode
$(ApplicationDisplayVersion)
->android:versionName
Conditionally add
generated\*\*.cs
to@(Compile)
(#6280, PR #6291, Commit 33e92cab)Fix more
Mono.Android.dll
linker warnings
(PR #6270, Commit 141da855)Prefer
/manifest/@package
over$(ApplicationId)
(#6302, PR #6304, Commit 0a6f9bd8)Fixes an install-time
XA0132
error caused by a mismatch between the two values.Add EventPipe tracing support
(PR #6022, Commit 0f7a0cde)Use
mono_unhandled_exception
for NET6
(PR #6104, Commit c1a2ee70)add missing property in
AndroidMessageHandler
(PR #6303, Commit d61aae7f)Fixes IL2037 warning.
Fix
DynamicDependency
toJavaArray
(PR #6105, Commit 6f9bc6b2)Fixes IL2036 warning.
Speed up P/Invoke override lookups
(PR #6210, Commit 38aa561a)
Thank you
A big Thank You! to community members who contributed improvements in this release
Feedback welcome
Your feedback is important to us. If there are any problems with this release, check our GitHub Issues, Xamarin.Android Community Forums and Visual Studio Developer Community for existing issues. For new issues within the Xamarin.Android SDK, please report a GitHub Issue. For general Xamarin.Android experience issues, let us know via the Report a Problem option found in your favorite IDE under Help > Report a Problem.
Open source
Xamarin.Android 12.0 is based on the open-source Xamarin.Android repositories:
- Core JNI interaction logic is in the Java.Interop repo.
- Android bindings and MSBuild tooling are in the xamarin-android repo.
- Chat is in the #android channel on the DotNetEvolution Discord server.