{
  "id": "unity/il2cpp-missing-method",
  "signature": "IL2CPP error: System.MissingMethodException: Method not found: 'Void UnityEngine.UI.Image::set_sprite(UnityEngine.Sprite)'",
  "signature_zh": "IL2CPP 错误：System.MissingMethodException：找不到方法：'Void UnityEngine.UI.Image::set_sprite(UnityEngine.Sprite)'",
  "regex": "IL2CPP error: System\\.MissingMethodException: Method not found: '.*'",
  "domain": "unity",
  "category": "build_error",
  "subcategory": null,
  "root_cause": "IL2CPP code stripping removes a method that is referenced via reflection or a code path not visible to the linker.",
  "root_cause_type": "generic",
  "root_cause_zh": "IL2CPP 代码剥离删除了通过反射或链接器不可见的代码路径引用的方法。",
  "versions": [
    {
      "version": "2021.3.30f1",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "2022.3.10f1",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "6000.0.0b12",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Preserve only works on specific methods or fields, not entire files; may not cover all reflection paths.",
      "fail_rate": 0.65,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Disabling stripping increases build size significantly and may hide but not fix the underlying reflection issue.",
      "fail_rate": 0.4,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "The issue is in IL2CPP code generation, not asset import; rebuild doesn't change stripping behavior.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Add [Preserve] attribute to the specific method: `[Preserve] private void SetSpriteMethod(Sprite s) { image.sprite = s; }`",
      "success_rate": 0.85,
      "how": "Add [Preserve] attribute to the specific method: `[Preserve] private void SetSpriteMethod(Sprite s) { image.sprite = s; }`",
      "condition": "",
      "sources": []
    },
    {
      "action": "Create a link.xml file in Assets/Plugins with: <linker><assembly fullname=\"UnityEngine.UI\"><type fullname=\"UnityEngine.UI.Image\" preserve=\"all\"/></assembly></linker>",
      "success_rate": 0.92,
      "how": "Create a link.xml file in Assets/Plugins with: <linker><assembly fullname=\"UnityEngine.UI\"><type fullname=\"UnityEngine.UI.Image\" preserve=\"all\"/></assembly></linker>",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use `#if !UNITY_EDITOR` to force a direct call to the method in a startup script so IL2CPP sees it",
      "success_rate": 0.75,
      "how": "Use `#if !UNITY_EDITOR` to force a direct call to the method in a startup script so IL2CPP sees it",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Add [Preserve] attribute to the specific method: `[Preserve] private void SetSpriteMethod(Sprite s) { image.sprite = s; }`",
    "Create a link.xml file in Assets/Plugins with: <linker><assembly fullname=\"UnityEngine.UI\"><type fullname=\"UnityEngine.UI.Image\" preserve=\"all\"/></assembly></linker>",
    "Use `#if !UNITY_EDITOR` to force a direct call to the method in a startup script so IL2CPP sees it"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://docs.unity3d.com/Manual/IL2CPP-ErrorTroubleshooting.html",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.85,
  "fix_success_rate": 0.78,
  "resolvable": "true",
  "first_seen": "2023-08-14",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}