From e7674c4a5f38870e85588e9672127db3cc2e3270 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Thu, 14 May 2026 22:25:30 +0000
Subject: [PATCH 1/3] Initial plan
From 2f8c9b6e7cc706d30c547e07ca60694fffc330ab Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Thu, 14 May 2026 22:47:55 +0000
Subject: [PATCH 2/3] Move hardcoded error strings in
GenerateJniRemappingNativeCode to Properties.Resources with XA1045-XA1047
error codes
Agent-Logs-Url: https://github.com/dotnet/android/sessions/895d450d-8ee0-42ba-a920-784ef258ec94
Co-authored-by: jonathanpeppers <840039+jonathanpeppers@users.noreply.github.com>
---
.../Properties/Resources.Designer.cs | 27 +++++++++++++++++++
.../Properties/Resources.resx | 12 +++++++++
.../Tasks/GenerateJniRemappingNativeCode.cs | 6 ++---
3 files changed, 42 insertions(+), 3 deletions(-)
diff --git a/src/Xamarin.Android.Build.Tasks/Properties/Resources.Designer.cs b/src/Xamarin.Android.Build.Tasks/Properties/Resources.Designer.cs
index 890e2142dd1..866c61a4187 100644
--- a/src/Xamarin.Android.Build.Tasks/Properties/Resources.Designer.cs
+++ b/src/Xamarin.Android.Build.Tasks/Properties/Resources.Designer.cs
@@ -965,6 +965,33 @@ public static string XA1044 {
}
}
+ ///
+ /// Looks up a localized string similar to Input file `{0}` does not start with `<replacements/>`..
+ ///
+ public static string XA1045 {
+ get {
+ return ResourceManager.GetString("XA1045", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Attribute '{0}' in element '{1}' has value '{2}' that cannot be parsed as boolean; {3} line {4}..
+ ///
+ public static string XA1046 {
+ get {
+ return ResourceManager.GetString("XA1046", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Required attribute '{0}' missing from element '{1}'; {2} line {3}..
+ ///
+ public static string XA1047 {
+ get {
+ return ResourceManager.GetString("XA1047", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Use of AppDomain.CreateDomain() detected in assembly: {0}. .NET 6 and higher will only support a single AppDomain, so this API will no longer be available in .NET for Android once .NET 6 is released..
///
diff --git a/src/Xamarin.Android.Build.Tasks/Properties/Resources.resx b/src/Xamarin.Android.Build.Tasks/Properties/Resources.resx
index ae4698f69eb..c612cd39776 100644
--- a/src/Xamarin.Android.Build.Tasks/Properties/Resources.resx
+++ b/src/Xamarin.Android.Build.Tasks/Properties/Resources.resx
@@ -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).
+
+ Input file `{0}` does not start with `<replacements/>`.
+ {0} - file path
+
+
+ Attribute '{0}' in element '{1}' has value '{2}' that cannot be parsed as boolean; {3} line {4}.
+ {0} - attribute name; {1} - element name; {2} - attribute value; {3} - file path; {4} - line number
+
+
+ Required attribute '{0}' missing from element '{1}'; {2} line {3}.
+ {0} - attribute name; {1} - element name; {2} - file path; {3} - line number
+
Java dependency '{0}' is not satisfied.
The following are literal names and should not be translated: Java.
diff --git a/src/Xamarin.Android.Build.Tasks/Tasks/GenerateJniRemappingNativeCode.cs b/src/Xamarin.Android.Build.Tasks/Tasks/GenerateJniRemappingNativeCode.cs
index 7da71df76e3..16cf42c3533 100644
--- a/src/Xamarin.Android.Build.Tasks/Tasks/GenerateJniRemappingNativeCode.cs
+++ b/src/Xamarin.Android.Build.Tasks/Tasks/GenerateJniRemappingNativeCode.cs
@@ -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 ``");
+ Log.LogCodedError ("XA1045", Properties.Resources.XA1045, remappingXmlFilePath);
} else {
ReadXml (reader, typeReplacements, methodReplacements, remappingXmlFilePath);
}
@@ -131,7 +131,7 @@ void ReadXml (XmlReader reader, List 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;
}
@@ -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;
}
From a63ec27ffb81d57a467568a5a570c5eaf19caa0c Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Fri, 15 May 2026 13:55:30 +0000
Subject: [PATCH 3/3] Add documentation markdown files for XA1044-XA1047 error
codes and update index.md TOC
Agent-Logs-Url: https://github.com/dotnet/android/sessions/19a56121-fdbe-45d4-84be-ea0f62355b6b
Co-authored-by: jonathanpeppers <840039+jonathanpeppers@users.noreply.github.com>
---
Documentation/docs-mobile/messages/index.md | 4 ++
Documentation/docs-mobile/messages/xa1045.md | 32 +++++++++++++
Documentation/docs-mobile/messages/xa1046.md | 38 +++++++++++++++
Documentation/docs-mobile/messages/xa1047.md | 50 ++++++++++++++++++++
4 files changed, 124 insertions(+)
create mode 100644 Documentation/docs-mobile/messages/xa1045.md
create mode 100644 Documentation/docs-mobile/messages/xa1046.md
create mode 100644 Documentation/docs-mobile/messages/xa1047.md
diff --git a/Documentation/docs-mobile/messages/index.md b/Documentation/docs-mobile/messages/index.md
index 14d5a6c0442..aba425bd35e 100644
--- a/Documentation/docs-mobile/messages/index.md
+++ b/Documentation/docs-mobile/messages/index.md
@@ -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 ``.
++ [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
diff --git a/Documentation/docs-mobile/messages/xa1045.md b/Documentation/docs-mobile/messages/xa1045.md
new file mode 100644
index 00000000000..b49ade8c949
--- /dev/null
+++ b/Documentation/docs-mobile/messages/xa1045.md
@@ -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 ``.
+```
+
+## Issue
+
+The JNI remapping XML file referenced by the `$(AndroidJniRemapping)` MSBuild
+item does not have the expected `` root element. The file must
+begin with a `` element for the build system to process it.
+
+## Solution
+
+Ensure the JNI remapping XML file starts with a `` root element.
+For example:
+
+```xml
+
+
+
+```
diff --git a/Documentation/docs-mobile/messages/xa1046.md b/Documentation/docs-mobile/messages/xa1046.md
new file mode 100644
index 00000000000..012580ae97f
--- /dev/null
+++ b/Documentation/docs-mobile/messages/xa1046.md
@@ -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 ``
+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
+
+
+
+```
diff --git a/Documentation/docs-mobile/messages/xa1047.md b/Documentation/docs-mobile/messages/xa1047.md
new file mode 100644
index 00000000000..86a817dd38b
--- /dev/null
+++ b/Documentation/docs-mobile/messages/xa1047.md
@@ -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 `` and `` elements each have required
+attributes that must be present.
+
+Required attributes for ``:
+- `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 ``:
+- `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
+
+
+
+
+```