Skip to content
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,7 @@ Possible values include:
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.
- **JavaInterop1**: this value is obsolete and is no longer supported.

The default value is `XAJavaInterop1`.

Expand Down
2 changes: 1 addition & 1 deletion Documentation/docs-mobile/messages/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,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`.
2 changes: 1 addition & 1 deletion Documentation/guides/OneDotNet.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ will not be supported.
supported.

`$(AndroidCodegenTarget)` will be `XAJavaInterop1` by default.
`XamarinAndroid` will not be supported.
`XamarinAndroid` and `JavaInterop1` will not be supported.

`$(AndroidManifest)` will default to `AndroidManifest.xml` in the root
of projects as `Properties\AssemblyInfo.cs` is no longer used in
Expand Down
5 changes: 3 additions & 2 deletions Documentation/guides/OneDotNetBindingProjects.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ will always be used.

### `<AndroidCodegenTarget>`

`XamarinAndroid` is no longer a valid option for `<AndroidCodegenTarget>`. `XAJavaInterop1`
is now the default and only supported option.
`XamarinAndroid` and `JavaInterop1` are no longer valid options for
`<AndroidCodegenTarget>`. `XAJavaInterop1` is now the default and only
supported option.

If you have hand-bound code in your `Additions` files that interacts with the generated binding
plumbing (which is rare), it may need to be updated to be compatible with `XAJavaInterop1`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,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 '$(_AndroidRuntime)' != 'NativeAOT' ">llvm-ir</_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>
Comment thread
simonrozsival marked this conversation as resolved.
<!-- .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 @@ -725,8 +725,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 @@ -44,5 +44,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 @@ -3003,6 +3003,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' " />
</Target>

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