Skip to content
Merged
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
4 changes: 4 additions & 0 deletions Documentation/docs-mobile/messages/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,10 @@ Either change the value in the AndroidManifest.xml to match the $(SupportedOSPla
+ [XA1039](xa1039.md): The Android Support libraries are not supported in .NET 9 and later, please migrate to AndroidX. See https://aka.ms/xamarin/androidx for more details.
+ [XA1040](xa1040.md): The NativeAOT runtime on Android is an experimental feature and not yet suitable for production use. File issues at: https://github.com/dotnet/android/issues
+ [XA1041](xa1041.md): The MSBuild property 'MonoAndroidAssetPrefix' has an invalid value of 'c:\Foo\Assets'. The value is expected to be a directory path representing the relative location of your Assets or Resources
+ [XA1044](xa1044.md): The MSBuild property '{0}' is not compatible with the {1} runtime. The build cannot continue while this property is enabled.
+ [XA1045](xa1045.md): Input file `{0}` does not start with `<replacements/>`.
+ [XA1046](xa1046.md): Attribute '{0}' in element '{1}' has value '{2}' that cannot be parsed as boolean; {3} line {4}.
+ [XA1047](xa1047.md): Required attribute '{0}' missing from element '{1}'; {2} line {3}.

## XA2xxx: Linker

Expand Down
32 changes: 32 additions & 0 deletions Documentation/docs-mobile/messages/xa1045.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
title: .NET for Android error XA1045
description: XA1045 error code
ms.date: 05/15/2026
f1_keywords:
- "XA1045"
---

# .NET for Android error XA1045

## Example messages

```
error XA1045: Input file `/path/to/jni-remapping.xml` does not start with `<replacements/>`.
```

## Issue

The JNI remapping XML file referenced by the `$(AndroidJniRemapping)` MSBuild
item does not have the expected `<replacements/>` root element. The file must
begin with a `<replacements>` element for the build system to process it.

## Solution

Ensure the JNI remapping XML file starts with a `<replacements>` root element.
For example:

```xml
<replacements>
<replace-type from="com/example/Old" to="com/example/New" />
</replacements>
```
38 changes: 38 additions & 0 deletions Documentation/docs-mobile/messages/xa1046.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
title: .NET for Android error XA1046
description: XA1046 error code
ms.date: 05/15/2026
f1_keywords:
- "XA1046"
---

# .NET for Android error XA1046

## Example messages

```
error XA1046: Attribute 'target-method-instance-to-static' in element 'replace-method' has value 'yes' that cannot be parsed as boolean; /path/to/jni-remapping.xml line 5.
```

## Issue

The `target-method-instance-to-static` attribute of a `<replace-method>`
element in the JNI remapping XML file contains a value that cannot be parsed
as a boolean. The attribute requires a valid boolean value such as `true` or
`false`.

## Solution

Update the `target-method-instance-to-static` attribute in your JNI remapping
XML file to use a valid boolean value (`true` or `false`):

```xml
<replacements>
<replace-method
source-type="com/example/Source"
source-method-name="instanceMethod"
target-type="com/example/Target"
target-method-name="staticMethod"
target-method-instance-to-static="true" />
</replacements>
```
50 changes: 50 additions & 0 deletions Documentation/docs-mobile/messages/xa1047.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
title: .NET for Android error XA1047
description: XA1047 error code
ms.date: 05/15/2026
f1_keywords:
- "XA1047"
---

# .NET for Android error XA1047

## Example messages

```
error XA1047: Required attribute 'from' missing from element 'replace-type'; /path/to/jni-remapping.xml line 3.
error XA1047: Required attribute 'source-type' missing from element 'replace-method'; /path/to/jni-remapping.xml line 7.
```

## Issue

A required attribute is missing from an element in the JNI remapping XML file.
The `<replace-type>` and `<replace-method>` elements each have required
attributes that must be present.

Required attributes for `<replace-type>`:
- `from` — the original Java type name (e.g. `com/example/OldClass`)
- `to` — the replacement Java type name (e.g. `com/example/NewClass`)

Required attributes for `<replace-method>`:
- `source-type` — the Java type containing the original method
- `source-method-name` — the name of the original method
- `target-type` — the Java type containing the replacement method
- `target-method-name` — the name of the replacement method
- `target-method-instance-to-static` — whether the replacement converts an instance method to a static method (`true` or `false`)

## Solution

Add the missing required attributes to the element in your JNI remapping XML
file. For example:

```xml
<replacements>
<replace-type from="com/example/OldClass" to="com/example/NewClass" />
<replace-method
source-type="com/example/Source"
source-method-name="instanceMethod"
target-type="com/example/Target"
target-method-name="staticMethod"
target-method-instance-to-static="true" />
</replacements>
```

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

12 changes: 12 additions & 0 deletions src/Xamarin.Android.Build.Tasks/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1015,6 +1015,18 @@ To use a custom JDK path for a command line build, set the 'JavaSdkDirectory' MS
{1} - The name of the .NET runtime (e.g. CoreCLR, NativeAOT).
</comment>
</data>
<data name="XA1045" xml:space="preserve">
<value>Input file `{0}` does not start with `&lt;replacements/&gt;`.</value>
<comment>{0} - file path</comment>
</data>
<data name="XA1046" xml:space="preserve">
<value>Attribute '{0}' in element '{1}' has value '{2}' that cannot be parsed as boolean; {3} line {4}.</value>
<comment>{0} - attribute name; {1} - element name; {2} - attribute value; {3} - file path; {4} - line number</comment>
</data>
<data name="XA1047" xml:space="preserve">
<value>Required attribute '{0}' missing from element '{1}'; {2} line {3}.</value>
<comment>{0} - attribute name; {1} - element name; {2} - file path; {3} - line number</comment>
</data>
<data name="XA4241" xml:space="preserve">
<value>Java dependency '{0}' is not satisfied.</value>
<comment>The following are literal names and should not be translated: Java.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ void Generate (string remappingXmlFilePath)

using (var reader = XmlReader.Create (File.OpenRead (remappingXmlFilePath), readerSettings)) {
if (reader.MoveToContent () != XmlNodeType.Element || reader.LocalName != "replacements") {
Log.LogError ($"Input file `{remappingXmlFilePath}` does not start with `<replacements/>`");
Log.LogCodedError ("XA1045", Properties.Resources.XA1045, remappingXmlFilePath);
} else {
ReadXml (reader, typeReplacements, methodReplacements, remappingXmlFilePath);
}
Expand Down Expand Up @@ -131,7 +131,7 @@ void ReadXml (XmlReader reader, List<JniRemappingTypeReplacement> typeReplacemen
}

if (!Boolean.TryParse (targetIsStatic, out bool isStatic)) {
Log.LogError ($"Attribute 'target-method-instance-to-static' in element '{reader.LocalName}' value '{targetIsStatic}' cannot be parsed as boolean; {remappingXmlFilePath} line {GetCurrentLineNumber ()}");
Log.LogCodedError ("XA1046", Properties.Resources.XA1046, "target-method-instance-to-static", reader.LocalName, targetIsStatic, remappingXmlFilePath, GetCurrentLineNumber ());
continue;
}

Expand All @@ -152,7 +152,7 @@ bool GetRequiredAttribute (string attributeName, out string attributeValue)
return true;
}

Log.LogError ($"Attribute '{attributeName}' missing from element '{reader.LocalName}'; {remappingXmlFilePath} line {GetCurrentLineNumber ()}");
Log.LogCodedError ("XA1047", Properties.Resources.XA1047, attributeName, reader.LocalName, remappingXmlFilePath, GetCurrentLineNumber ());
return false;
}

Expand Down