.NET for Android 错误 XA1047

示例消息

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

JNI 重新映射 XML 文件中的元素缺少必需的属性。 <replace-method> 元素和 <replace-type> 元素都必须包含必需属性。

<replace-type> 所需的属性:

  • from— 原始Java类型名称(例如com/example/OldClass)
  • to— 替换Java类型名称(例如com/example/NewClass)

<replace-method> 的必需属性:

  • source-type— 包含原始方法的Java类型
  • source-method-name — 原始方法的名称
  • target-type— 包含替换方法的Java类型
  • target-method-name — 替换方法的名称
  • target-method-instance-to-static — 替换者是否将实例方法转换为静态方法(true 或 false)

解决方案

将缺少的必需属性添加到 JNI 重新映射 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>