Düzenle

Build properties

MSBuild properties control the behavior of the targets.

They're specified within the project file, for example MyApp.csproj, within an MSBuild PropertyGroup.

Note

In .NET for Android there is technically no distinction between an application and a bindings project, so properties will work in both. In practice it is highly recommended to create separate application and bindings projects. Properties that are primarily used in bindings projects are documented in the MSBuild bindings project properties reference guide.

Runtime scope

Ordinary Android applications target CoreCLR in .NET 11 and later. Android applications targeting .NET 10 and earlier use Mono by default. Setting $(PublishAot) to true selects the NativeAOT runtime for supported publish or optimized builds and takes precedence over $(UseMonoRuntime).

$(UseMonoRuntime)=true is not a .NET 11 escape hatch. The .NET 11 SDK rejects it with NETSDK1242. Use the .NET 10-and-earlier Mono guidance only when targeting a framework where Mono is supported.

AdbTarget

The $(AdbTarget) property specifies the Android target device the Android package may be installed to or removed from. The value of this property is the same as the adb Target Device option.

AfterGenerateAndroidManifest

MSBuild Targets listed in this property will run directly after the internal _GenerateJavaStubs target, which is where the AndroidManifest.xml file is generated in the $(IntermediateOutputPath). If you want to make any modifications to the generated AndroidManifest.xml file, you can do that using this extension point.

AndroidAapt2CompileExtraArgs

Specifies command-line options to pass to the aapt2 compile command when processing Android assets and resources.

AndroidAapt2LinkExtraArgs

Specifies command-line options to pass to the aapt2 link command when processing Android assets and resources.

AndroidAddKeepAlives

A boolean property that controls whether the linker will insert GC.KeepAlive() invocations within binding projects to prevent premature object collection.

The default value is True for Release configuration builds.

For untrimmed builds using the trimmable type map, GC.KeepAlive() calls are only inserted when $(AndroidEnableLegacyCompatibilityAssemblyFixups) is also True. Trimmed builds using the trimmable type map do not insert these calls.

AndroidAotAdditionalArguments

A string property that allows passing options to the Mono compiler during the Aot task for projects that have either $(AndroidEnableProfiledAot) or $(AotAssemblies) set to true. The string value of the property is added to the response file when calling the Mono cross-compiler.

In general, this property should be left blank, but in certain special scenarios it might provide useful flexibility.

The $(AndroidAotAdditionalArguments) property is different from the related $(AndroidExtraAotOptions) property; $(AndroidAotAdditionalArguments) passes full standalone space-separated options like --verbose or --debug to the AOT compiler, while $(AndroidExtraAotOptions) contains comma-separated arguments which are part of the --aot option of the AOT compiler.

AndroidAotCustomProfilePath

The file that aprofutil should create to hold profiler data.

AndroidAotProfiles

A string property that allows the developer to add AOT profiles from the command line. It's a semicolon or comma-separated list of absolute paths.

AndroidAotProfilerPort

The port that aprofutil should connect to when obtaining profiling data.

AndroidAotEnableLazyLoad

Enable lazy (delayed) loading of AOT-d assemblies, instead of preloading them at the startup. The default value is True for Release builds with any form of AOT enabled.

Introduced in .NET 6.

AndroidApkDigestAlgorithm

A string value that specifies the digest algorithm to use with jarsigner -digestalg.

The default value is SHA-256.

AndroidApkSignerAdditionalArguments

A string property that allows the developer to provide arguments to the apksigner tool.

AndroidApkSigningAlgorithm

A string value that specifies the signing algorithm to use with jarsigner -sigalg.

The default value is SHA256withRSA.

AndroidApplication

A boolean value that indicates whether the project is for an Android Application (True) or for an Android Library Project (False or not present).

Only one project with <AndroidApplication>True</AndroidApplication> may be present within an Android package. (Unfortunately this requirement isn't verified, which can result in subtle and bizarre errors regarding Android resources.)

AndroidApplicationJavaClass

The full Java class name to use in place of android.app.Application when a class inherits from Android.App.Application.

The $(AndroidApplicationJavaClass) property is generally set by other properties, such as the $(AndroidEnableMultiDex) MSBuild property.

AndroidAvoidEmitForPerformance

A boolean property that determines whether or not System.Reflection.Emit is "avoided" to improve startup performance. This property is True by default.

Usage of System.Reflection.Emit has a noticeable impact on startup performance on Android. This behavior is disabled by default for the following feature switches:

  • Switch.System.Reflection.ForceInterpretedInvoke: after the second call to MethodInfo.Invoke() or ConstructorInfo.Invoke(), code is emitted to improve performance of repeated calls.

  • Microsoft.Extensions.DependencyInjection.DisableDynamicEngine: after the second call to retrieve a service from a dependency injection container, code is emitted to improve performance of repeated calls.

It is desirable in most Android applications to disable this behavior.

See the Base Class Libraries Feature Switches documentation for details about available feature switches.

Added in .NET 8.

AndroidBinUtilsPath

A path to a directory containing the Android binutils such as ld, the native linker, and as, the native assembler. These tools are included in the .NET for Android workload.

The default value is $(MonoAndroidBinDirectory)\binutils\bin\.

AndroidBoundExceptionType

A string value that specifies how exceptions should be propagated when a .NET for Android-provided type implements a .NET type or interface in terms of Java types, for example Android.Runtime.InputStreamInvoker and System.IO.Stream, or Android.Runtime.JavaDictionary and System.Collections.IDictionary.

  • Java: The original Java exception type is propagated as-is.

    Java means that, for example, InputStreamInvoker doesn't properly implement the System.IO.Stream API because Java.IO.IOException may be thrown from Stream.Read() instead of System.IO.IOException.

  • System: The original Java exception type is caught and wrapped in an appropriate .NET exception type.

    System means that, for example, InputStreamInvoker properly implements System.IO.Stream, and Stream.Read() will not throw Java.IO.IOException instances. (It may instead throw a System.IO.IOException containing a Java.IO.IOException as the Exception.InnerException value.)

    System is the default value.

AndroidBoundInterfacesContainConstants

A boolean property that determines whether binding constants on interfaces will be supported, or the workaround of creating an IMyInterfaceConsts class will be used.

The default value is True.

AndroidBoundInterfacesContainStaticAndDefaultInterfaceMethods

A boolean property that whether default and static members on interfaces will be supported, or old workaround of creating a sibling class containing static members like abstract class MyInterface.

The default value is True in .NET 6 and False for legacy.

AndroidBoundInterfacesContainTypes

A boolean property that whether types nested in interfaces will be supported, or the workaround of creating a non-nested type like IMyInterfaceMyNestedClass.

The default value is True in .NET 6 and False for legacy.

AndroidBuildApplicationPackage

A boolean value that indicates whether to create and sign the package (.apk). Setting this value to True is equivalent to using the SignAndroidPackage build target.

This property is False by default.

AndroidBundleConfigurationFile

Specifies a filename to use as a configuration file for bundletool when building an Android App Bundle. This file controls some aspects of how APKs are generated from the bundle, such as on what dimensions the bundle is split to produce APKs. .NET for Android configures some of these settings automatically, including the list of file extensions to leave uncompressed.

This property is only relevant if $(AndroidPackageFormat) is set to aab.

AndroidBundleToolExtraArgs

Specifies command-line options to pass to the bundletool command when build app bundles.

AndroidClassParser

A string property that controls how .jar files are parsed. Possible values include:

  • class-parse: Uses class-parse.exe to parse Java bytecode directly, without assistance of a JVM.

  • jar2xml: this value is obsolete and is no longer supported.

AndroidCodegenTarget

A string property that controls the code generation target ABI. Possible values include:

  • XamarinAndroid: this value is obsolete and is no longer supported.

  • XAJavaInterop1: Use Java.Interop for JNI invocations. Binding assemblies using XAJavaInterop1 can only build and execute with Xamarin.Android 6.1 or later. Xamarin.Android 6.1 and later bind Mono.Android.dll with this value.

  • JavaInterop1: experimental value, currently the default for the NativeAOT runtime.

The default value is XAJavaInterop1.

AndroidCreatePackagePerAbi

A boolean property that determines if a set of files--one per ABI specified in $(AndroidSupportedAbis)--should be created instead of having support for all ABIs in a single .apk.

See also the Building ABI-Specific APKs guide.

AndroidCreateProguardMappingFile

A boolean property that controls if a proguard mapping file is generated as part of the build process.

Adding the following to your csproj will cause the file to be generated, and uses the AndroidProguardMappingFile property to control the location of the final mapping file.

<AndroidCreateProguardMappingFile>True</AndroidCreateProguardMappingFile>

When producing .aab files, the mapping file is automatically included in your package. There is no need to upload it to the Google Play Store manually. When using .apk files, the AndroidProguardMappingFile will need to be manually uploaded.

The default value is True when using $(AndroidLinkTool)=r8.

AndroidDebugKeyAlgorithm

Specifies the default algorithm to use for the debug.keystore. The default value is RSA.

AndroidDebugKeyValidity

Specifies the default validity to use for the debug.keystore. The default value is 10950 or 30 * 365 or 30 years.

AndroidDebugStoreType

Specifies the key store file format to use for the debug.keystore. It defaults to pkcs12.

AndroidDeviceUserId

Allows deploying and debugging the application under guest or work accounts. The value is the uid value you get from the following adb command:

adb shell pm list users

The above command will return the following data:

Users:
	UserInfo{0:Owner:c13} running
	UserInfo{10:Guest:404}

The uid is the first integer value. In the above output, they're 0 and 10.

AndroidDexTool

An enum-style property with a valid value of d8. Previously, a value of dx was supported in Xamarin.Android.

Indicates which Android dex compiler is used during the .NET for Android build process. The default value is d8. See our documentation on D8 and R8.

AndroidEnableDesugar

A boolean property that determines if desugar is enabled. Android doesn't currently support all Java 8 features, and the default toolchain implements the new language features by performing bytecode transformations, called desugar, on the output of the javac compiler. The default value is False if using $(AndroidDexTool)=dx and True if using $(AndroidDexTool)=d8.

AndroidEnableFastDeployment

A boolean property that determines whether Fast Deployment is enabled. Fast Deployment installs assemblies outside of the application package, which can reduce deployment and rebuild times.

The default value is True for Debug builds and False for Release builds. Setting this property is equivalent to setting the inverse value of $(EmbedAssembliesIntoApk). If both properties are set, $(EmbedAssembliesIntoApk) takes precedence.

AndroidEnableGooglePlayStoreChecks

A bool property that allows developers to disable the following Google Play Store checks: XA1004, XA1005 and XA1006. Disabling these checks is useful for developers who are not targeting the Google Play Store and do not wish to run those checks.

AndroidEnableLegacyCompatibilityAssemblyFixups

A boolean property that controls whether untrimmed builds modify referenced assemblies to support legacy binding and resource designer behavior. These modifications include adding missing abstract interface methods, updating legacy resource designer references, and inserting GC.KeepAlive() calls into older Xamarin.Android binding assemblies. Trimmed builds using the trimmable type map do not run these compatibility fixups, and setting this property to True does not enable them for trimmed builds.

The default value is False when $(AndroidTypeMapImplementation) is trimmable, and True otherwise.

AndroidEnableMarshalMethods

A bool property, that determines whether or not LLVM marshal methods are enabled. LLVM marshal methods are an app startup optimization which uses native entry points for Java native method registration.

This property is False by default.

This property cannot be set to true when $(PublishReadyToRun) is true.

Added in .NET 8.

AndroidEnableMultiDex

A boolean property that determines whether or not multi-dex support will be used in the final .apk.

This property is False by default.

AndroidEnableProfiler

For Mono applications, this is a synonym for the $(EnableDiagnostics) property. If it is true, the Mono diagnostic component, libmono-component-diagnostics_tracing.so, is included in the application.

For CoreCLR applications in .NET 11 and later, this property enables the CoreCLR diagnostic-port configuration used by tools such as dotnet-trace and dotnet-gcdump; it does not add a Mono diagnostic component. NativeAOT is a separate runtime selected by $(PublishAot) and this property documents only the supported Android packaging and configuration behavior.

This property is False by default.

AndroidEnableObsoleteOverrideInheritance

A boolean property that determines if bound methods automatically inherit [Obsolete] attributes from methods they override.

Support for this property was added in .NET 8.

This property is True by default.

AndroidEnablePreloadAssemblies

A boolean property that controls whether or not all managed assemblies bundled within the application package are loaded during process startup or not.

When set to True, all assemblies bundled within the application package will be loaded during process startup, before any application code is invoked.

When set to False, assemblies will only be loaded on an as-needed basis. Loading assemblies on an as-needed basis allows applications to launch faster, and is also more consistent with desktop .NET semantics. To see the time savings, set the debug.mono.log System Property to include timing, and look for the Finished loading assemblies: preloaded message within adb logcat.

Applications or libraries, which use dependency injection may require that this property be True if they in turn require that AppDomain.CurrentDomain.GetAssemblies() return all assemblies within the application bundle, even if the assembly wouldn't otherwise have been needed.

By default this value is False.

AndroidEnableProfiledAot

A boolean property that determines whether or not the AOT profiles are used during Ahead-of-Time compilation.

The profiles are listed in @(AndroidAotProfile) item group. This ItemGroup contains default profile(s). It can be overridden by removing the existing one(s) and adding your own AOT profiles.

This property is False by default.

AndroidEnableRestrictToAttributes

An enum-style property with valid values of obsolete and disable.

When set to obsolete, types and members that are marked with the Java annotation androidx.annotation.RestrictTo or are in non-exported Java packages will be marked with an [Obsolete] attribute in the C# binding.

This [Obsolete] attribute has a descriptive message explaining that the Java package owner considers the API to be "internal" and warns against its use.

This attribute also has a custom warning code XAOBS001 so that it can be suppressed independently of "normal" obsolete API.

When set to disable, API will be generated as normal with no additional attributes. (This is the same behavior as before .NET 8.)

Adding [Obsolete] attributes instead of automatically removing the API was done to preserve API compatibility with existing packages. If you would instead prefer to remove members that have the @RestrictTo annotation or are in non-exported Java packages, you can use Transform files in addition to this property to prevent these types from being bound:

<remove-node path="//*[@annotated-visibility]" />

Support for this property was added in .NET 8.

This property is set to obsolete by default.

AndroidEnableSGenConcurrent

A boolean property that determines whether or not Mono's concurrent GC collector will be used.

This property is False by default.

AndroidErrorOnCustomJavaObject

A boolean property that determines whether types may implement Android.Runtime.IJavaObject without also inheriting from Java.Lang.Object or Java.Lang.Throwable:

class BadType : IJavaObject {
    public IntPtr Handle {
        get {return IntPtr.Zero;}
    }

    public void Dispose()
    {
    }
}

When True, such types will generate an XA4212 error, otherwise an XA4212 warning will be generated.

This property is True by default.

AndroidExplicitCrunch

This property is no longer supported.

AndroidExtraAotOptions

A string property that allows passing options to the Mono compiler during the Aot task for projects that have either $(AndroidEnableProfiledAot) or $(AotAssemblies) set to true. The string value of the property is added to the response file when calling the Mono cross-compiler.

In general, this property should be left blank, but in certain special scenarios it might provide useful flexibility.

The $(AndroidExtraAotOptions) property is different from the related $(AndroidAotAdditionalArguments) property; $(AndroidAotAdditionalArguments) places comma-separated arguments into the --aot option of the Mono compiler. $(AndroidExtraAotOptions) instead passes full standalone space-separated options like --verbose or --debug to the compiler.

AndroidFastDeploymentType

This property was removed in .NET 9 and has no effect.

AndroidFragmentType

Specifies the default fully qualified type to be used for all <fragment> layout elements when generating the layout bindings code. The default value is the standard Android Android.App.Fragment type.

AndroidGenerateJniMarshalMethods

This experimental feature was removed in .NET 11. Setting the property has no effect.

AndroidGenerateJniMarshalMethodsAdditionalArguments

This experimental feature was removed in .NET 11. Setting the property has no effect.

AndroidGenerateLayoutBindings

Enables generation of layout code-behind if set to true or disables it completely if set to false.

The default value is false.

AndroidGenerateResourceDesigner

The default value is true. When set to false, disables the generation of Resource.designer.cs.

AndroidHttpClientHandlerType

Note

This property is not supported in .NET 11. Remove it from your project file and use UseNativeHttpHandler instead.

AndroidIgnoreAllJniPreload

A boolean value which, if set to true, exempts all the native JNI libraries from being preloaded at application startup. By default, all such libraries will be loaded by the runtime early during application startup in order to assure their proper initialization. However, in some cases it might not be the desired behavior and this property allows you to effectively disable it.

Some framework libraries which must be loaded at application startup will not be affected by this property.

See also @(AndroidNativeLibraryNoJniPreload) for a more fine-grained way to exempt libraries from the preload mechanism.

AndroidIncludeWrapSh

A boolean value that indicates whether the Android wrapper script (wrap.sh) should be packaged into the APK. The default value is false since the wrapper script may significantly influence the way the application starts up and works and the script should be included only when necessary, for example when debugging or otherwise changing the application startup/runtime behavior.

The script is added to the project using the @(AndroidNativeLibrary) build action, because it is placed in the same directory as architecture-specific native libraries, and must be named wrap.sh.

The easiest way to specify path to the wrap.sh script is to put it in a directory named after the target architecture. This approach will work if you have just one wrap.sh per architecture:

<AndroidNativeLibrary Include="path/to/arm64-v8a/wrap.sh" />

However, if your project needs more than one wrap.sh per architecture, for different purposes, this approach won't work. Instead, in such cases the name can be specified using the Link metadata of the AndroidNativeLibrary:

<AndroidNativeLibrary Include="/path/to/my/arm64-wrap.sh">
  <Link>lib\arm64-v8a\wrap.sh</Link>
</AndroidNativeLibrary>

If the Link metadata is used, the path specified in its value must be a valid native architecture-specific library path, relative to the APK root directory. The format of the path is lib\ARCH\wrap.sh where ARCH can be one of:

  • arm64-v8a
  • armeabi-v7a
  • x86_64
  • x86

AndroidIncludeAssetPacksInPackage

This property controls if an Asset Packs build automatically are auto included in the final .aab file. It will default to true.

In certain cases the user might want to release an interim release. In these cases the user does not need to update the asset pack. Especially if the contents of the asset pack have not changed. This property allows the user to skip the asset packs if they are not required.

Added in .NET 9

AndroidInstallJavaDependencies

The default value is true for command line builds. When set to true, enables installation of the Java SDK when running the <InstallAndroidDependencies/> target.

Support for this property was added in .NET 9.

AndroidInstrumentation

A string property that specifies the Android instrumentation runner class name to use when launching the application via dotnet run.

When this property is not set, dotnet run resolves what to launch from the generated AndroidManifest.xml in the intermediate output:

  • If $(AndroidUseInstrumentation) is true, the first <instrumentation/> element is used.
  • Otherwise the launchable <activity/> is preferred, and the first <instrumentation/> element is used when the app declares no launchable activity. This makes it possible to dotnet run an app whose only entry point is an Android.App.Instrumentation subclass, such as a BenchmarkDotNet host.

If the app declares neither, the build fails with XA1043. If $(AndroidUseInstrumentation) is true but the app declares no <instrumentation/>, the build fails with XA1048.

When an instrumentation is launched, dotnet run runs adb shell am instrument -w -r and exits with a non-zero exit code if the instrumentation crashes or calls Instrumentation.Finish() with Result.Canceled. Setting $(WaitForExit) to false drops the -w, so dotnet run returns as soon as the instrumentation is started and no results are reported.

Any arguments after -- are forwarded to the instrumentation as am instrument extras. Arguments of the form KEY=VALUE become -e KEY VALUE, and all remaining arguments are joined into a single -e args "..." extra:

dotnet run -- --filter *MyBenchmark*

is delivered to Instrumentation.OnCreate(Bundle?) as arguments.GetString("args").

Introduced in .NET 11.

AndroidJavadocVerbosity

Specifies how "verbose" C# XML Documentation Comments should be when importing Javadoc documentation within binding projects.

Requires use of the @(JavaSourceJar) build action.

The $(AndroidJavadocVerbosity) property is enum-like, with possible values of full or intellisense:

The default value is intellisense.

AndroidKeyStore

A boolean value that indicates whether custom signing information should be used. The default value is False, meaning that the default debug-signing key will be used to sign packages.

AndroidLaunchActivity

The Android activity to launch.

AndroidLinkMode

Specifies which type of linking should be performed on assemblies contained within the Android package. Only used in Android Application projects. The default value is SdkOnly. Valid values are:

  • None: No linking will be attempted.

  • SdkOnly: Linking will be performed on the base class libraries only, not user's assemblies.

  • Full: Linking will be performed on base class libraries and user assemblies.

    Note

    Using an AndroidLinkMode value of Full often results in broken apps, particularly when Reflection is used. Avoid unless you really know what you're doing.

<AndroidLinkMode>SdkOnly</AndroidLinkMode>

AndroidLinkResources

When true, the build system will link out the Nested Types of the Resource.Designer.cs Resource class in all assemblies. The IL code that uses those types will be updated to use the values directly rather than accessing fields.

Linking out the nested types can have a small impact on reducing the apk size, and can also help with startup performance. Only "Release" builds are linked.

Experimental. Only designed to work with code such as

var view = FindViewById(Resources.Ids.foo);

Any other scenarios (such as reflection) will not be supported.

AndroidLinkSkip

Specifies a semicolon-delimited (;) list of assembly names, without file extensions, of assemblies that should not be linked. Only used within Android Application projects.

<AndroidLinkSkip>Assembly1;Assembly2</AndroidLinkSkip>

AndroidLinkTool

An enum-style property with valid values of proguard or r8. Indicates which code shrinker is used for Java code. The default value is an empty string, or proguard if $(AndroidEnableProguard) is True. See our documentation on D8 and R8.

AndroidLintEnabled

A bool property that allows the developer to run the android lint tool as part of the packaging process.

When $(AndroidLintEnabled)=True, the following properties are used:

The following build actions may also be used:

See Lint Help for more details on the android lint tooling.

AndroidLintEnabledIssues

A string property that is a comma-separated list of lint issues to enable.

Only used when $(AndroidLintEnabled)=True.

AndroidLintDisabledIssues

A string property that is a comma-separated list of lint issues to disable.

Only used when $(AndroidLintEnabled)=True.

AndroidLintCheckIssues

A string property that is a comma-separated list of lint issues to check.

Only used when $(AndroidLintEnabled)=True.

Note: only these issues will be checked.

AndroidManagedSymbols

A boolean property that controls whether sequence points are generated so that file name and line number information can be extracted from Release stack traces.

AndroidManifest

Specifies a filename to use as the template for the app's AndroidManifest.xml. During the build, any other necessary values will be merged into to produce the actual AndroidManifest.xml. The $(AndroidManifest) must contain the package name in the /manifest/@package attribute.

AndroidManifestMerger

Specifies the implementation for merging AndroidManifest.xml files. This is an enum-style property where legacy selects the original C# implementation and manifestmerger.jar selects Google's Java implementation.

The default value is currently manifestmerger.jar. If you want to use the old version add the following to your csproj

<AndroidManifestMerger>legacy</AndroidManifestMerger>

Google's merger enables support for xmlns:tools="http://schemas.android.com/tools" as described in the Android documentation.

AndroidManifestMergerExtraArgs

A string property to provide arguments to the Android documentation tool.

If you want detailed output from the tool you can add the following to the .csproj.

<AndroidManifestMergerExtraArgs>--log VERBOSE</AndroidManifestMergerExtraArgs>

AndroidManifestType

An enum-style property with valid values of Xamarin or GoogleV2. This controls which repository is used by the InstallAndroidDependencies target to determine which Android packages and package versions are available and can be installed.

Xamarin is the Approved List (Recommended) repository within the Visual Studio SDK Manager.

GoogleV2 is the Full List (Unsupported) repository within the Visual Studio SDK Manager.

If $(AndroidManifestType) is not set, then Xamarin is used.

AndroidManifestSource

A string property that specifies an absolute URI or an existing local file path for the repository manifest used by the InstallAndroidDependencies target. When this property is not set, the default repository manifest selected by $(AndroidManifestType) is used.

For example:

<AndroidManifestSource>https://example.com/AndroidManifestFeed.xml</AndroidManifestSource>

AndroidManifestPlaceholders

A semicolon-separated list of key-value replacement pairs for AndroidManifest.xml, where each pair has the format key=value.

For example, a property value of assemblyName=$(AssemblyName) defines an ${assemblyName} placeholder that can then appear in AndroidManifest.xml:

<application android:label="${assemblyName}"

This provides a way to insert variables from the build process into the AndroidManifest.xml file.

AndroidMultiDexClassListExtraArgs

A string property which allows developers to pass arguments to the com.android.multidex.MainDexListBuilder when generating the multidex.keep file.

One specific case is if you are getting the following error during the dx compilation.

com.android.dex.DexException: Too many classes in --main-dex-list, main dex capacity exceeded

If you are getting this error you can add the following to the .csproj.

<DxExtraArguments>--force-jumbo </DxExtraArguments>
<AndroidMultiDexClassListExtraArgs>--disable-annotation-resolution-workaround</AndroidMultiDexClassListExtraArgs>

which will allow the dx step to succeed.

AndroidNdkDirectory

The $(AndroidNdkDirectory) property specifies a custom Android NDK installation directory. The path can be set in the project file or on the command line:

dotnet build -p:AndroidNdkDirectory=/path/to/android-ndk

If this property is not set, .NET for Android locates the NDK from the configured Android development environment.

AndroidPackageFormat

An enum-style property with valid values of apk or aab. Indicates if you want to package the Android application as an APK file or Android App Bundle. App Bundles are a new format for Release builds that are intended for submission on Google Play. The default value is apk.

When $(AndroidPackageFormat) is set to aab, other MSBuild properties are set, which are required for Android App Bundles:

This property will be deprecated for .net 6. Users should switch over to the newer AndroidPackageFormats.

AndroidPackageFormats

A semi-colon delimited property with valid values of apk and aab. Indicates if you want to package the Android application as an APK file or Android App Bundle. App Bundles are a new format for Release builds that are intended for submission on Google Play.

When building a Release build you might want to generate both and aab and an apk for distribution to various stores.

Setting AndroidPackageFormats to aab;apk will result in both being generated. Setting AndroidPackageFormats to either aab or apk will generate only one file.

The default value is aab;apk for Release builds only. Using apk for debugging is faster, but aab is also supported with fast deployment if needed (for example, when testing asset packs).

AndroidPackageNamingPolicy

An enum-style property for specifying the Java package names of generated Java source code.

The only supported value is LowercaseCrc64.

AndroidPrepareForBuildDependsOn

A semi-colon delimited property that can be used to extend the Android build process. MSBuild targets added to this property will execute early in the build for both Application and Library project types. This property is empty by default.

Example:

<PropertyGroup>
  <AndroidPrepareForBuildDependsOn>MyCustomTarget</AndroidPrepareForBuildDependsOn>
</PropertyGroup>

<Target Name="MyCustomTarget" >
  <Message Text="Running target: 'MyCustomTarget'" Importance="high"  />
</Target>

AndroidProguardMappingFile

Specifies the -printmapping proguard rule for r8. This will mean the mapping.txt file will be produced in the $(OutputPath) folder. This file can then be used when uploading packages to the Google Play Store.

By default this file is produced automatically when using AndroidLinkTool=r8 and will generate the following file $(OutputPath)mapping.txt.

If you do not want to generate this mapping file you can use the AndroidCreateProguardMappingFile property to stop creating it . Add the following in your project

<AndroidCreateProguardMappingFile>False</AndroidCreateProguardMappingFile>

or use -p:AndroidCreateProguardMappingFile=False on the command line.

AndroidD8IgnoreWarnings

Specifies --map-diagnostics warning info to be passed to d8. The default value is True, but can be set to False to enforce more strict behavior. See the D8 and R8 source code for details.

Added in .NET 8.

AndroidR8IgnoreWarnings

Specifies the -ignorewarnings proguard rule for r8. This allows r8 to continue with dex compilation even if certain warnings are encountered. The default value is True, but can be set to False to enforce more strict behavior. See the ProGuard manual for details.

Starting in .NET 8, specifies --map-diagnostics warning info. See the D8 and R8 source code for details.

AndroidR8JarPath

The path to r8.jar for use with the r8 dex-compiler and shrinker. The default value is a path into the .NET for Android workload installation. For further information see our documentation on D8 and R8.

AndroidR8ObfuscationMode

An enum-style property that specifies how r8 obfuscates Java names when $(AndroidLinkTool) is r8. Supported values are:

  • private-members preserves Java class and interface names and public or protected member names. Private and package-private members can be obfuscated, and R8 optimization is enabled.
  • disabled disables obfuscation, preserves all Java names, and uses the non-optimizing Android R8 defaults.

This property does not disable R8 code shrinking.

This property was introduced in a .NET 10 servicing release. It defaults to disabled in .NET 10 and to private-members in .NET 11 and later.

AndroidResgenExtraArgs

Specifies command-line options to pass to the aapt command when processing Android assets and resources.

AndroidResgenFile

Specifies the name of the Resource file to generate. The default template sets this to Resource.designer.cs.

AndroidResourceDesignerClassModifier

Specifies the class modifier for the intermediate Resource class which is generated. Valid values are public and internal.

By default this will be public.

Added in .NET 9.

AndroidSdkBuildToolsVersion

The Android SDK build-tools package provides the aapt and zipalign tools, among others. Multiple different versions of the build-tools package may be installed simultaneously. The build-tools package chosen for packaging is done by checking for and using a "preferred" build-tools version if it is present; if the "preferred" version is not present, then the highest versioned installed build-tools package is used.

The $(AndroidSdkBuildToolsVersion) MSBuild property contains the preferred build-tools version. The .NET for Android build system provides a default value in Xamarin.Android.Common.targets, and the default value may be overridden within your project file to choose an alternate build-tools version, if (for example) the latest aapt is crashing out while a previous aapt version is known to work.

AndroidSigningKeyAlias

Specifies the alias for the key in the keystore. This is the keytool -alias value used when creating the keystore.

AndroidSigningKeyPass

Specifies the password of the key within the keystore file. This is the value entered when keytool asks Enter key password for $(AndroidSigningKeyAlias).

This property also supports env: and file: prefixes that can be used to specify an environment variable or file that contains the password. These options provide a way to prevent the password from appearing in build logs.

For example, to use an environment variable named AndroidSigningPassword:

<PropertyGroup>
  <AndroidSigningKeyPass>env:AndroidSigningPassword</AndroidSigningKeyPass>
</PropertyGroup>

To use a file located at C:\Users\user1\AndroidSigningPassword.txt:

<PropertyGroup>
  <AndroidSigningKeyPass>file:C:\Users\user1\AndroidSigningPassword.txt</AndroidSigningKeyPass>
</PropertyGroup>

Note

The env: prefix is not supported when $(AndroidPackageFormat) is set to aab.

AndroidSigningKeyStore

Specifies the filename of the keystore file created by keytool. This corresponds to the value provided to the keytool -keystore option.

AndroidSigningStorePass

Specifies the password to $(AndroidSigningKeyStore). This is the value provided to keytool when creating the keystore file and asked Enter keystore password:.

This property also supports env: and file: prefixes that can be used to specify an environment variable or file that contains the password. These options provide a way to prevent the password from appearing in build logs.

For example, to use an environment variable named AndroidSigningPassword:

<PropertyGroup>
  <AndroidSigningStorePass>env:AndroidSigningPassword</AndroidSigningStorePass>
</PropertyGroup>

To use a file located at C:\Users\user1\AndroidSigningPassword.txt:

<PropertyGroup>
  <AndroidSigningStorePass>file:C:\Users\user1\AndroidSigningPassword.txt</AndroidSigningStorePass>
</PropertyGroup>

Note

The env: prefix is not supported when $(AndroidPackageFormat) is set to aab.

AndroidSigningPlatformKey

Specifies the key file to use to sign the apk. This is only used when building system applications.

AndroidSigningPlatformCert

Specifies the certificate file to use to sign the apk. This is only used when building system applications.

AndroidStripILAfterAOT

A bool property that specifies whether or not the method bodies of AOT compiled methods will be removed.

The default value is false, and the method bodies of AOT compiled methods will not be removed.

When set to true, $(AndroidEnableProfiledAot) is set to false by default. This means that in Release configuration builds -- in which $(RunAOTCompilation) is true by default -- AOT is enabled for everything. This can result in increased app sizes. This behavior can be overridden by explicitly setting $(AndroidEnableProfiledAot) to true within your project file.

Experimental support for this property was added in .NET 8, removed in .NET 10.

AndroidStripNativeLibraries

A bool property which tells the packaging process to strip debug symbols from the native shared libraries (.so files).

The default value is false and the debug symbols, if any, will be preserved when packaging.

AndroidSupportedAbis

A string property that contains a semicolon (;)-delimited list of ABIs which should be included into the .apk.

Supported values include:

  • armeabi-v7a
  • x86
  • arm64-v8a
  • x86_64

AndroidTlsProvider

This property is obsolete and should not be used.

AndroidTypeMapImplementation

An enum-style property that selects the type map implementation. Valid values are llvm-ir and trimmable.

The default value is trimmable when $(PublishAot) is true and llvm-ir otherwise.

AndroidUseApkSigner

A bool property that allows the developer to use the apksigner tool rather than jarsigner.

AndroidUseDefaultAotProfile

A bool property that allows the developer to suppress usage of the default AOT profiles.

To suppress the default AOT profiles, set the property to false.

AndroidUseDesignerAssembly

A bool property which controls if the build system will generate an _Microsoft.Android.Resource.Designer.dll as apposed to a Resource.Designer.cs file. The benefits of this are smaller applications and faster startup time.

The default value is true in .NET 8.

As a Nuget Author it is recommended that you ship three versions of the assembly if you want to maintain backward compatibility. One for MonoAndroid, one for net6.0-android and one for net8.0-android. You can do this by using Xamarin.Legacy.Sdk. This is only required if your Nuget Library project makes use of AndroidResource items in the project or via a dependency.

<TargetFrameworks>monoandroid90;net6.0-android;net8.0-android</TargetFrameworks>

Alternatively turn this setting off until such time as both Classic and net7.0-android have been deprecated.

.NET 8 Projects which choose to turn this setting off will not be able to consume references which do use it. If you try to use an assembly which does have this feature enabled in a project that does not, you will get a XA1034 build error.

Added in .NET 8.

AndroidUseInstrumentation

A boolean property that indicates the application is launched through its <instrumentation/> element rather than an <activity/>, such as a test or BenchmarkDotNet host.

When true, dotnet run resolves $(AndroidInstrumentation) from the generated AndroidManifest.xml and launches it with adb shell am instrument, even if the app also declares a launchable activity.

The default value is true when $(EnableMSTestRunner) is true, and false otherwise. Note that an app with no launchable <activity/> launches through its <instrumentation/> regardless of this property.

Introduced in .NET 11.

AndroidUseInterpreter

A boolean property that causes a MonoVM .apk to contain the Mono interpreter, and not the normal JIT. It is a Mono-only setting and is not a CoreCLR setting. Android has no interpreter in .NET 11 and later.

Experimental.

AndroidUseLegacyVersionCode

A boolean property that allows the developer to revert the versionCode calculation back to its old pre Xamarin.Android 8.2 behavior. This should ONLY be used for developers with existing applications in the Google Play Store. It is highly recommended that the new $(AndroidVersionCodePattern) property is used.

AndroidUseManagedDesignTimeResourceGenerator

A boolean property that will switch over the design time builds to use the managed resource parser rather than aapt.

AndroidUseNegotiateAuthentication

A boolean property that enables support for NTLMv2/Negotiate authentication in AndroidMessageHandler. The default value is False.

Added in .NET 7.

AndroidUseSharedRuntime

This property is obsolete and should not be used.

AndroidVersionCode

An MSBuild property that can be used as an alternative to /manifest/@android:versionCode in the AndroidManifest.xml file. To opt into this feature you must also enable <GenerateApplicationManifest>true</GenerateApplicationManifest>. This will be the default going forward in .NET 6.

This property is ignored if $(AndroidCreatePackagePerAbi) and $(AndroidVersionCodePattern) are used.

@android:versionCode is an integer value that must be incremented for each Google Play release. See the Android documentation for further details about the requirements for /manifest/@android:versionCode.

AndroidVersionCodePattern

A string property that allows the developer to customize the versionCode in the manifest. See Creating the Version Code for the APK for information on deciding a versionCode.

Some examples, if abi is armeabi and versionCode in the manifest is 123, {abi}{versionCode} will produce a versionCode of 1123 when $(AndroidCreatePackagePerAbi) is True, otherwise will produce a value of 123. If abi is x86_64 and versionCode in the manifest is 44. This will produce 544 when $(AndroidCreatePackagePerAbi) is True, otherwise will produce a value of 44.

If we include a left padding format string {abi}{versionCode:0000}, it would produce 50044 because we are left padding the versionCode with 0. Alternatively, you can use the decimal padding such as {abi}{versionCode:D4} which does the same as the previous example.

Only '0' and 'Dx' padding format strings are supported since the value MUST be an integer.

Pre-defined key items

  • abi – Inserts the targeted abi for the app

    • 2 – armeabi-v7a
    • 3 – x86
    • 4 – arm64-v8a
    • 5 – x86_64
  • minSDK – Inserts the minimum supported Sdk value from the AndroidManifest.xml or 11 if none is defined.

  • versionCode – Uses the version code directly from Properties\AndroidManifest.xml.

You can define custom items using the $(AndroidVersionCodeProperties) property (defined next).

By default the value will be set to {abi}{versionCode:D6}. If a developer wants to keep the old behavior you can override the default by setting the $(AndroidUseLegacyVersionCode) property to true

AndroidVersionCodeProperties

A string property that allows the developer to define custom items to use with the $(AndroidVersionCodePattern). They are in the form of a key=value pair. All items in the value should be integer values. For example: screen=23;target=$(_AndroidApiLevel). As you can see you can make use of existing or custom MSBuild properties in the string.

ApplicationId

An MSBuild property that can be used as an alternative to /manifest/@package in the AndroidManifest.xml file. To opt into this feature you must also enable <GenerateApplicationManifest>true</GenerateApplicationManifest>. This will be the default going forward in .NET 6.

See the Android documentation for further details about the requirements for /manifest/@package.

ApplicationTitle

An MSBuild property that can be used as an alternative to /manifest/application/@android:label in the AndroidManifest.xml file. To opt into this feature you must also enable <GenerateApplicationManifest>true</GenerateApplicationManifest>. This will be the default going forward in .NET 6.

See the Android documentation for further details about the requirements for /manifest/application/@android:label.

ApplicationVersion

An MSBuild property that can be used as an alternative to /manifest/@android:versionName in the AndroidManifest.xml file. To opt into this feature you must also enable <GenerateApplicationManifest>true</GenerateApplicationManifest>. This will be the default going forward in .NET 6.

See the Android documentation for further details about the requirements for /manifest/@android:versionName.

AotAssemblies

A boolean property that determines whether or not assemblies will be Ahead-of-Time compiled into native code and included in applications. This property is False by default.

Deprecated in .NET 7. Migrate to the new $(RunAOTCompilation) MSBuild property instead, as support for $(AotAssemblies) will be removed in a future release.

AProfUtilExtraOptions

Extra options to pass to aprofutil.

BeforeBuildAndroidAssetPacks

MSBuild Targets listed in this property will run directly before the AssetPack items are built.

Added in .NET 9

BeforeGenerateAndroidManifest

MSBuild Targets listed in this property will run directly before _GenerateJavaStubs.

Configuration

Specifies the build configuration to use, such as "Debug" or "Release". The Configuration property is used to determine default values for other properties which determine target behavior. Additional configurations may be created within your IDE.

By default, the Debug configuration will result in the Install and SignAndroidPackage targets creating a smaller Android package which requires the presence of other files and packages to operate.

The default Release configuration will result in the Install and SignAndroidPackage targets creating an Android package which is stand-alone, and may be used without installing any other packages or files.

DebugSymbols

A boolean value that determines whether the Android package is debuggable, in combination with the $(DebugType) property. A debuggable package contains debug symbols, sets the //application/@android:debuggable attribute to true, and automatically adds the INTERNET permission so that a debugger can attach to the process. An application is debuggable if DebugSymbols is True and DebugType is either the empty string or Full.

DebugType

Specifies the type of debug symbols to generate as part of the build, which also impacts whether the Application is debuggable. Possible values include:

  • Full: Full symbols are generated. If the DebugSymbols MSBuild property is also True, then the Application package is debuggable.

  • PdbOnly: "PDB" symbols are generated. The Application package is not debuggable.

If DebugType is not set or is the empty string, then the DebugSymbols property controls whether or not the Application is debuggable.

Device

Specifies which Android device or emulator to target when using dotnet run --device <Device> or MSBuild targets that interact with devices (such as Run, Install, or Uninstall).

The value must be the full device serial number or identifier as returned by adb devices. For example, if the device serial is emulator-5554, you must use -p:Device=emulator-5554.

When set, this property is used to initialize the AdbTarget property with the value -s "<Device>".

For more information about device selection, see the .NET SDK device selection specification.

DiagnosticAddress

A value provided by dotnet-dsrouter such as 127.0.0.1, the IP address component of $(DiagnosticConfiguration) or DOTNET_DiagnosticPorts.

When this property is nonempty and $(AndroidEnableProfiler) is not explicitly set to false, it implicitly enables Android diagnostics. For CoreCLR, the resulting TCP endpoint is normally kept on loopback and is used by dotnet-dsrouter. For an Android emulator, use 10.0.2.2 to reach the development machine; for a physical device, use 127.0.0.1 with Android port forwarding enabled by dotnet-dsrouter server-server --tcp-server 127.0.0.1:9000 --forward-port Android.

Defaults to 127.0.0.1.

DiagnosticConfiguration

A value provided by dotnet-dsrouter for DOTNET_DiagnosticPorts such as:

  • 127.0.0.1:9000,connect,suspend
  • 127.0.0.1:9000,connect,nosuspend

When diagnostics are enabled without an explicit configuration, the derived defaults are address 127.0.0.1, port 9000, DiagnosticSuspend=false, and DiagnosticListenMode=connect.

Note that the , character will need to be escaped with %2c if passed in command-line to dotnet build:

dotnet build -c Release -p:DiagnosticConfiguration=127.0.0.1:9000%2cconnect%2csuspend

This automatically sets the DOTNET_DiagnosticPorts environment variable packaged inside the application. In connect mode, the Android runtime connects to the configured TCP endpoint and dotnet-dsrouter bridges that connection to the local diagnostic tool. The endpoint is unauthenticated and unencrypted, so keep it on a local development interface.

Setting this property, or any of the component properties below, implicitly enables Android diagnostics when $(AndroidEnableProfiler) is not explicitly set to false.

DiagnosticListenMode

A value provided by dotnet-dsrouter such as connect, the listening mode component of $(DiagnosticConfiguration) or DOTNET_DiagnosticPorts.

When this property is nonempty and $(AndroidEnableProfiler) is not explicitly set to false, it implicitly enables Android diagnostics.

Defaults to connect.

DiagnosticPort

A value provided by dotnet-dsrouter such as 9000, the port component of $(DiagnosticConfiguration) or DOTNET_DiagnosticPorts.

When this property is nonempty and $(AndroidEnableProfiler) is not explicitly set to false, it implicitly enables Android diagnostics.

Defaults to 9000.

DiagnosticSuspend

A boolean value provided by dotnet-dsrouter such as true/suspend or false/nosuspend, a component of $(DiagnosticConfiguration) or DOTNET_DiagnosticPorts.

When this property is nonempty and $(AndroidEnableProfiler) is not explicitly set to false, it implicitly enables Android diagnostics.

Defaults to false.

EmbedAssembliesIntoApk

A boolean property that determines whether or not the app's assemblies should be embedded into the Application package.

This property is the inverse of $(AndroidEnableFastDeployment). New projects should use $(AndroidEnableFastDeployment) to control Fast Deployment. If both properties are set, $(EmbedAssembliesIntoApk) takes precedence.

This property should be True for Release builds and False for Debug builds. It may need to be True in Debug builds if Fast Deployment doesn't support the target device.

EnableCrashReport

A boolean property that sets the DOTNET_EnableCrashReport environment variable to 1 when using the CoreCLR or NativeAOT runtime. This enables crash report generation at application startup.

This property is False by default and is ignored when $(UseMonoRuntime) is True.

EnableDiagnostics

An Android SDK/MSBuild property that enables diagnostics for the selected runtime. It is a synonym for $(AndroidEnableProfiler) for Mono applications. For CoreCLR, it enables the diagnostic-port configuration used by dotnet-trace and dotnet-gcdump.

$(EnableDiagnostics) is not the same as the CoreCLR runtime environment variable DOTNET_EnableDiagnostics. The former is evaluated by the Android SDK/MSBuild targets; the latter is read by the runtime when supplied as an environment variable.

This property is False by default.

EnableLLVM

A boolean property that determines whether or not LLVM will be used when Ahead-of-Time compiling assemblies into native code.

The Android NDK must be installed to build a project that has this property enabled.

This property is False by default.

This property is ignored unless the $(AotAssemblies) MSBuild property is True.

EnableMSTestRunner

A boolean property that enables the MSTest runner for Android test projects. When set to true, dotnet run will launch the application via am instrument instead of am start, allowing test results to be reported through Android's instrumentation protocol.

This property is False by default.

Introduced in .NET 11.

EnableProguard

A boolean property that determines whether or not proguard is run as part of the packaging process to link Java code.

This property is False by default.

When True, @(ProguardConfiguration) files will be used to control proguard execution.

EventSourceSupport

When set to false, disables .NET's EventSource support from trimmed Android applications. Disabling this feature would prevent .NET diagnostic tools like dotnet-counters from functioning, but at the benefit of reduced application size.

Set to false by default in Release mode, unless $(EnableDiagnostics) or $(AndroidEnableProfiler) are enabled.

GenerateApplicationManifest

Enables or disables the following MSBuild properties that emit values in the final AndroidManifest.xml file:

The default value $(GenerateApplicationManifest) is true.

JavaMaximumHeapSize

Specifies the value of the java -Xmx parameter value to use when building the .dex file as part of the packaging process. If not specified, then the -Xmx option supplies java with a value of 1G. This was found to be commonly required on Windows in comparison to other platforms.

Specifying this property is necessary if the _CompileDex target throws a java.lang.OutOfMemoryError.

Customize the value by changing:

<JavaMaximumHeapSize>1G</JavaMaximumHeapSize>

JavaOptions

Specifies command-line options to pass to java when building the .dex file.

JarsignerTimestampAuthorityCertificateAlias

This property allows you to specify an alias in the keystore for a timestamp authority. See the Java Signature Timestamp Support documentation for more details.

<PropertyGroup>
    <JarsignerTimestampAuthorityCertificateAlias>Alias</JarsignerTimestampAuthorityCertificateAlias>
</PropertyGroup>

JarsignerTimestampAuthorityUrl

This property allows you to specify a URL to a timestamp authority service. This can be used to make sure your .apk signature includes a timestamp. See the Java Signature Timestamp Support documentation for more details.

<PropertyGroup>
    <JarsignerTimestampAuthorityUrl>http://example.tsa.url</JarsignerTimestampAuthorityUrl>
</PropertyGroup>

LinkerDumpDependencies

A bool property that enables generating of linker dependencies file. This file can be used as input for illinkanalyzer tool.

The dependencies file named linker-dependencies.xml.gz is written to the project directory. On .NET5/6 it is written next to the linked assemblies in obj/<Configuration>/android<ABI>/linked directory.

The default value is False.

MandroidI18n

This MSBuild property is obsolete and is no longer supported.

MauiEnableFullReadyToRun

A boolean property for .NET MAUI Android applications that use CoreCLR and are built in Release configuration with ReadyToRun enabled. When this property is unset or false, MAUI uses partial ReadyToRun with its default MIBC profiles. Set this property to true to enable full ReadyToRun. This property has no effect when $(PublishReadyToRun) is false.

Full ReadyToRun increases application and download size, but can potentially improve runtime performance because more methods are precompiled.

For more information about CoreCLR and ReadyToRun in .NET MAUI, see Runtimes and compilation in .NET MAUI.

MetricsSupport

When set to false, disables .NET's Metrics support from trimmed Android applications. Disabling this feature would prevent APIs such as System.Diagnostics.Metrics from functioning, but at the benefit of reduced application size.

Set to false by default in Release mode, unless $(EnableDiagnostics) or $(AndroidEnableProfiler) are enabled.

MonoAndroidAssetPrefix

Specifies a path prefix that is removed from the start of filenames with a Build action of AndroidAsset. This is to allow changing where resources are located.

The default value is Assets. Change this to assets for the Java project structure.

MonoAndroidResourcePrefix

Specifies a path prefix that is removed from the start of filenames with a Build action of AndroidResource. This is to allow changing where resources are located.

The default value is Resources. Change this to res for the Java project structure.

MonoSymbolArchive

Note

This was a legacy MSBuild property from Xamarin.Android. Not available in .NET 6+.

A boolean property that controls whether .mSYM artifacts are created for later use with mono-symbolicate, to extract “real” filename and line number information from Release stack traces.

This is True by default for “Release” apps which have debugging symbols enabled: $(EmbedAssembliesIntoApk) is True, $(DebugSymbols) is True, and $(Optimize) is True.

PublishReadyToRun

A boolean property that controls whether assemblies are compiled to ReadyToRun format when using CoreCLR. ReadyToRun assemblies contain both MSIL and native code. This can improve application startup time while retaining JIT compatibility, but increases application and download size.

For Android applications that use CoreCLR, this property defaults to true in Release configuration and is not enabled by default in Debug configuration. ReadyToRun does not apply when using Mono or NativeAOT.

ReadyToRun requires trimming. If $(PublishTrimmed) is not true, .NET for Android disables PublishReadyToRun and $(PublishReadyToRunComposite) and emits warning XA0119.

ReadyToRun compilation is composite by default. See $(PublishReadyToRunComposite). .NET MAUI also uses partial ReadyToRun with default MIBC profiles. See $(MauiEnableFullReadyToRun) to opt in to full ReadyToRun.

For more information, see Runtimes and compilation in .NET MAUI.

PublishReadyToRunComposite

A boolean property that controls whether ReadyToRun compilation combines application assemblies into a composite image. Composite ReadyToRun enables cross-assembly optimizations, but can increase build time.

For Android applications that use CoreCLR, this property defaults to true when $(PublishReadyToRun) is true. ReadyToRun, including composite ReadyToRun, requires $(PublishTrimmed) to be true.

RunAOTCompilation

A boolean property that determines whether or not assemblies will be Ahead-of-Time compiled with the Mono AOT compiler and included in applications that use the Mono runtime. This property is False by default for Debug builds and True by default for Release builds that use Mono. It does not enable ReadyToRun or NativeAOT.

This MSBuild property replaces the $(AotAssemblies) MSBuild property from Xamarin.Android. This is the same property used for Blazor WASM.

UseMonoRuntime

A boolean property that controls whether Android applications use the Mono runtime instead of CoreCLR for supported .NET 10-and-earlier targets. Set this property to true to use Mono or false to use CoreCLR on those targets. $(PublishAot) takes precedence and selects NativeAOT for supported publish or optimized builds when set to true.

This property defaults to true in .NET 10 and earlier, so Android applications use Mono. In .NET 11 and later, it defaults to false, so Android applications use CoreCLR, and an explicit true value is rejected with NETSDK1242.

For more information, see Runtimes and compilation in .NET MAUI.

WaitForExit

A boolean property that controls the behavior of dotnet run when launching Android applications.

When $(WaitForExit) is not false (the default), dotnet run will:

  • Launch the Android application
  • Stream logcat output filtered to the application's process
  • Wait for the application to exit or for the user to press Ctrl+C
  • Force-stop the application when Ctrl+C is pressed

When $(WaitForExit) is false, dotnet run will simply launch the application and return immediately without waiting for the application to exit or streaming any output.

This property also controls whether adb shell am instrument is passed -w when the application is launched through its $(AndroidInstrumentation):

$(WaitForExit) Launching an <activity/> Launching an <instrumentation/>
true (default) adb shell am start -S -W adb shell am instrument -w -r
false adb shell am start -S adb shell am instrument -r

Because adb shell am instrument only reports results once the instrumentation completes, $(WaitForExit) must not be false if you need the instrumentation's output or a meaningful exit code. This matters for scenarios such as running tests or a BenchmarkDotNet host, which is why dotnet test always uses the default.

Introduced in .NET 11.