Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Documentation/docs-mobile/messages/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ Either change the value in the AndroidManifest.xml to match the $(SupportedOSPla
+ XA4229: Unrecognized \`TransformFile\` root element: {element}.
+ XA4230: Error parsing XML: {exception}
+ [XA4231](xa4231.md): The Android class parser value 'jar2xml' is deprecated and will be removed in a future version of .NET for Android. Update the project properties to use 'class-parse'.
+ [XA4232](xa4232.md): The Android code generation target 'XamarinAndroid' is deprecated and will be removed in a future version of .NET for Android. Update the project properties to use 'XAJavaInterop1'.
+ [XA4232](xa4232.md): The Android code generation target '{0}' is no longer supported. The '_AndroidJcwCodegenTarget' property only supports 'XAJavaInterop1'; 'XamarinAndroid' and 'JavaInterop1' are not supported.
+ [XA4234](xa4234.md): '<{item}>' item '{itemspec}' is missing required attribute '{name}'.
+ [XA4235](xa4235.md): Maven artifact specification '{artifact}' is invalid. The correct format is 'group_id:artifact_id'.
+ [XA4236](xa4236.md): Cannot download Maven artifact '{group}:{artifact}'. - {jar}: {exception} - {aar}: {exception}
Expand Down
29 changes: 15 additions & 14 deletions Documentation/docs-mobile/messages/xa4232.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,34 @@
---
title: .NET for Android warning XA4232
description: XA4232 warning code
ms.date: 04/11/2024
title: .NET for Android error XA4232
description: XA4232 error code
ms.date: 07/17/2026
f1_keywords:
- "XA4232"
---

# .NET for Android warning XA4232
# .NET for Android error XA4232

## Example messages

```
warning XA4232: The Android code generation target 'XamarinAndroid' is deprecated and will be removed in a future version of .NET for Android. Update the project properties to use 'XAJavaInterop1'.
error XA4232: The Android code generation target 'XamarinAndroid' is no longer supported. The '_AndroidJcwCodegenTarget' property only supports 'XAJavaInterop1'; 'XamarinAndroid' and 'JavaInterop1' are not supported.
error XA4232: The Android code generation target 'JavaInterop1' is no longer supported. The '_AndroidJcwCodegenTarget' property only supports 'XAJavaInterop1'; 'XamarinAndroid' and 'JavaInterop1' are not supported.
```

## Issue

The Android code generation target `XamarinAndroid` has been deprecated.
The project sets the internal `_AndroidJcwCodegenTarget` MSBuild property to
`XamarinAndroid` or `JavaInterop1`. These code generation targets are no longer
supported for any .NET for Android runtime.

## Solution

To resolve this warning, update the **Android Codegen target** setting in the
Visual Studio project property pages or the **Code generation target** setting
in Visual Studio for Mac to **XAJavaInterop1**. This corresponds to the
`XAJavaInterop1` value for the `AndroidCodegenTarget` MSBuild property in the
_.csproj_ file:
Remove any `_AndroidJcwCodegenTarget` assignment that uses `XamarinAndroid` or
`JavaInterop1`, for example:

```xml
<PropertyGroup>
<AndroidCodegenTarget>XAJavaInterop1</AndroidCodegenTarget>
</PropertyGroup>
<_AndroidJcwCodegenTarget>JavaInterop1</_AndroidJcwCodegenTarget>
```

The property defaults to `XAJavaInterop1`. If a build customization must set
it explicitly, update the value to `XAJavaInterop1`.
9 changes: 9 additions & 0 deletions src/Mono.Android/Android.Runtime/AndroidRuntimeInternal.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
#if INSIDE_MONO_ANDROID_RUNTIME
using System;
using System.Reflection;
using System.Threading;
using Microsoft.Android.Runtime;

namespace Android.Runtime
{
public static class AndroidRuntimeInternal
{
internal static readonly Action<Exception> mono_unhandled_exception;
static int bridgeProcessingGeneration;

internal static int BridgeProcessingGeneration => Volatile.Read (ref bridgeProcessingGeneration);

#pragma warning disable CS0649 // Field is never assigned to. This field is assigned from monodroid-glue.cc.
internal static volatile bool BridgeProcessing; // = false
Expand Down Expand Up @@ -40,6 +44,11 @@ static void MonoUnhandledException (Exception ex)
RuntimeNativeMethods.monodroid_debugger_unhandled_exception (ex);
}

internal static void NotifyBridgeProcessingFinished ()
{
Interlocked.Increment (ref bridgeProcessingGeneration);
}

public static void WaitForBridgeProcessing ()
{
Java.Interop.JniEnvironment.Runtime.ValueManager.WaitForGCBridgeProcessing ();
Expand Down
5 changes: 5 additions & 0 deletions src/Mono.Android/Android.Runtime/JNIEnv.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@ public static void WaitForBridgeProcessing ()
JniEnvironment.Runtime.ValueManager.WaitForGCBridgeProcessing ();
}

/// <summary>
/// Gets the number of completed CoreCLR or NativeAOT GC bridge processing cycles.
/// </summary>
public static int BridgeProcessingGeneration => AndroidRuntimeInternal.BridgeProcessingGeneration;

public static IntPtr AllocObject (string jniClassName)
{
IntPtr jniClass = JNIEnv.FindClass (jniClassName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,8 @@ static unsafe void BridgeProcessingFinished (MarkCrossReferencesArgs* mcr)
#pragma warning disable CA1416
JavaMarshal.FinishCrossReferenceProcessing (mcr, handlesToFree);
#pragma warning restore CA1416

AndroidRuntimeInternal.NotifyBridgeProcessingFinished ();
}

static unsafe ReadOnlySpan<GCHandle> ProcessCollectedContexts (MarkCrossReferencesArgs* mcr)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#nullable enable
static Android.Runtime.JNIEnv.BridgeProcessingGeneration.get -> int
REMOVED Xamarin.Android.Net.AndroidClientHandler
REMOVED Xamarin.Android.Net.AndroidClientHandler.AndroidClientHandler() -> void
REMOVED Xamarin.Android.Net.AndroidClientHandler.AssertSelf() -> void
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#nullable enable
static Android.Runtime.JNIEnv.BridgeProcessingGeneration.get -> int
REMOVED Xamarin.Android.Net.AndroidClientHandler
REMOVED Xamarin.Android.Net.AndroidClientHandler.AndroidClientHandler() -> void
REMOVED Xamarin.Android.Net.AndroidClientHandler.AssertSelf() -> void
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#nullable enable
static Android.Runtime.JNIEnv.BridgeProcessingGeneration.get -> int
REMOVED Xamarin.Android.Net.AndroidClientHandler
REMOVED Xamarin.Android.Net.AndroidClientHandler.AndroidClientHandler() -> void
REMOVED Xamarin.Android.Net.AndroidClientHandler.AssertSelf() -> void
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#nullable enable
Android.App.ApplicationAttribute.EnableOnBackInvokedCallback.get -> bool
Android.App.ApplicationAttribute.EnableOnBackInvokedCallback.set -> void
static Android.Runtime.JNIEnv.BridgeProcessingGeneration.get -> int
Original file line number Diff line number Diff line change
Expand Up @@ -4349,6 +4349,7 @@ static Android.Ranging.Wifi.PD.WifiPdRangingCapabilities.Creator.get -> Android.
static Android.Ranging.Wifi.PD.WifiPdRangingParams.Creator.get -> Android.OS.IParcelableCreator!
static Android.Ranging.Wifi.Rtt.RttStationRangingParams.Creator.get -> Android.OS.IParcelableCreator!
static Android.Ranging.Wifi.Rtt.WifiRttSpecificData.Creator.get -> Android.OS.IParcelableCreator!
static Android.Runtime.JNIEnv.BridgeProcessingGeneration.get -> int
static Android.Runtime.JNIEnv.GetClassNameFromInstance(nint jobject) -> string?
static Android.Security.NetworkSecurityPolicy.Instance.get -> Android.Security.NetworkSecurityPolicy!
static Android.Service.Chooser.ChooserSessionToken.Creator.get -> Android.OS.IParcelableCreator!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<!-- jar2xml is not supported -->
<AndroidClassParser>class-parse</AndroidClassParser>
<AndroidCodegenTarget Condition=" '$(AndroidCodegenTarget)' == '' ">XAJavaInterop1</AndroidCodegenTarget>
<_AndroidJcwCodegenTarget Condition=" '$(_AndroidJcwCodegenTarget)' == '' and '$(_AndroidRuntime)' != 'NativeAOT' ">XAJavaInterop1</_AndroidJcwCodegenTarget>
<_AndroidJcwCodegenTarget Condition=" '$(_AndroidJcwCodegenTarget)' == '' ">XAJavaInterop1</_AndroidJcwCodegenTarget>
Comment thread
simonrozsival marked this conversation as resolved.
<AndroidTypeMapImplementation Condition=" '$(AndroidTypeMapImplementation)' == '' and '$(PublishAot)' == 'true' ">trimmable</AndroidTypeMapImplementation>
<AndroidBoundInterfacesContainStaticAndDefaultInterfaceMethods Condition=" '$(AndroidBoundInterfacesContainStaticAndDefaultInterfaceMethods)' == '' ">true</AndroidBoundInterfacesContainStaticAndDefaultInterfaceMethods>
<AndroidBoundInterfacesContainTypes Condition=" '$(AndroidBoundInterfacesContainTypes)' == '' ">true</AndroidBoundInterfacesContainTypes>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ This file contains the NativeAOT-specific MSBuild logic for .NET for Android.
<PropertyGroup>
<_AndroidRuntimePackRuntime>NativeAOT</_AndroidRuntimePackRuntime>
<_AndroidUseWorkloadNativeLinker Condition=" '$(_AndroidUseWorkloadNativeLinker)' == '' ">true</_AndroidUseWorkloadNativeLinker>
<_AndroidJcwCodegenTarget Condition=" '$(_AndroidJcwCodegenTarget)' == '' ">JavaInterop1</_AndroidJcwCodegenTarget>
<AndroidTypeMapImplementation Condition=" '$(AndroidTypeMapImplementation)' == '' ">trimmable</AndroidTypeMapImplementation>
<!-- .NET SDK gives: error NETSDK1191: A runtime identifier for the property 'PublishAot' couldn't be inferred. Specify a rid explicitly. -->
<AllowPublishAotWithoutRuntimeIdentifier Condition=" '$(AllowPublishAotWithoutRuntimeIdentifier)' == '' ">true</AllowPublishAotWithoutRuntimeIdentifier>
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/Xamarin.Android.Build.Tasks/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -730,8 +730,8 @@ In this message, "root element" refers to the root element of an XML file.
{0} - The name of the current class parser value</comment>
</data>
<data name="XA4232" xml:space="preserve">
<value>The Android code generation target '{0}' is deprecated and will be removed in a future version of .NET for Android. Update the project properties to use 'XAJavaInterop1'.</value>
<comment>The following are literal names and should not be translated: XAJavaInterop1
<value>The Android code generation target '{0}' is no longer supported. The '_AndroidJcwCodegenTarget' property only supports 'XAJavaInterop1'; 'XamarinAndroid' and 'JavaInterop1' are not supported.</value>
<comment>The following are literal names and should not be translated: _AndroidJcwCodegenTarget, XAJavaInterop1, XamarinAndroid, JavaInterop1
{0} - The name of the current code generation target</comment>
</data>
<data name="XA4300" xml:space="preserve">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,27 @@ public void XA0119AAB ()
}
}

[Test]
public void UnsupportedJcwCodegenTargetIsRejected (
[Values ("XamarinAndroid", "JavaInterop1")] string codegenTarget,
[Values (AndroidRuntime.MonoVM, AndroidRuntime.CoreCLR, AndroidRuntime.NativeAOT)] AndroidRuntime runtime)
{
var project = new XamarinAndroidApplicationProject {
IsRelease = runtime == AndroidRuntime.NativeAOT,
};
if (runtime == AndroidRuntime.MonoVM) {
project.SetProperty ("_DisableCheckForUnsupportedMonoMobileRuntime", "true");
}
project.SetRuntime (runtime);
project.SetProperty ("_AndroidJcwCodegenTarget", codegenTarget);
using (var builder = CreateApkBuilder ()) {
builder.Target = "_CheckForInvalidConfigurationAndPlatform";
builder.ThrowOnBuildFailure = false;
Assert.IsFalse (builder.Build (project), "Build should have failed.");
StringAssertEx.Contains ("error XA4232:", builder.LastBuildOutput, "Build should fail with XA4232.");
StringAssertEx.Contains (codegenTarget, builder.LastBuildOutput, "Error should identify the unsupported code generation target.");
}
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
"Size": 3124
},
"classes.dex": {
"Size": 22804
"Size": 404664
},
"lib/arm64-v8a/libUnnamedProject.so": {
"Size": 5747648
"Size": 5731688
},
"res/drawable-hdpi-v4/icon.png": {
"Size": 2178
Expand All @@ -35,5 +35,5 @@
"Size": 1904
}
},
"PackageSize": 2401051
"PackageSize": 2474779
}
Original file line number Diff line number Diff line change
Expand Up @@ -3042,6 +3042,14 @@ because xbuild doesn't support framework reference assemblies.

<Import Project="$(MSBuildThisFileDirectory)Xamarin.Installer.Common.targets"
Condition=" '$(DesignTimeBuild)' != 'true' "/>
<Target Name="_ValidateAndroidJcwCodegenTarget"
BeforeTargets="_CheckForInvalidConfigurationAndPlatform">
<AndroidError Code="XA4232"
ResourceName="XA4232"
FormatArguments="$(_AndroidJcwCodegenTarget)"
Condition=" '$(_AndroidJcwCodegenTarget)' == 'XamarinAndroid' or '$(_AndroidJcwCodegenTarget)' == 'JavaInterop1' " />
Comment thread
simonrozsival marked this conversation as resolved.
</Target>

<Target Name="_ValidateAndroidTypeMapImplementation"
BeforeTargets="_CheckForInvalidConfigurationAndPlatform">
<Error Condition=" '$(AndroidTypeMapImplementation)' != '' and '$(AndroidTypeMapImplementation)' != 'llvm-ir' and '$(AndroidTypeMapImplementation)' != 'trimmable' "
Expand Down
Loading