# IL2CPP error: System.MissingMethodException: Method not found: 'Void UnityEngine.UI.Image::set_sprite(UnityEngine.Sprite)'

- **ID:** `unity/il2cpp-missing-method`
- **Domain:** unity
- **Category:** build_error
- **Verification:** ai_generated
- **Fix Rate:** 78%

## Root Cause

IL2CPP code stripping removes a method that is referenced via reflection or a code path not visible to the linker.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 2021.3.30f1 | active | — | — |
| 2022.3.10f1 | active | — | — |
| 6000.0.0b12 | active | — | — |

## Workarounds

1. **Add [Preserve] attribute to the specific method: `[Preserve] private void SetSpriteMethod(Sprite s) { image.sprite = s; }`** (85% success)
   ```
   Add [Preserve] attribute to the specific method: `[Preserve] private void SetSpriteMethod(Sprite s) { image.sprite = s; }`
   ```
2. **Create a link.xml file in Assets/Plugins with: <linker><assembly fullname="UnityEngine.UI"><type fullname="UnityEngine.UI.Image" preserve="all"/></assembly></linker>** (92% success)
   ```
   Create a link.xml file in Assets/Plugins with: <linker><assembly fullname="UnityEngine.UI"><type fullname="UnityEngine.UI.Image" preserve="all"/></assembly></linker>
   ```
3. **Use `#if !UNITY_EDITOR` to force a direct call to the method in a startup script so IL2CPP sees it** (75% success)
   ```
   Use `#if !UNITY_EDITOR` to force a direct call to the method in a startup script so IL2CPP sees it
   ```

## Dead Ends

- **** — Preserve only works on specific methods or fields, not entire files; may not cover all reflection paths. (65% fail)
- **** — Disabling stripping increases build size significantly and may hide but not fix the underlying reflection issue. (40% fail)
- **** — The issue is in IL2CPP code generation, not asset import; rebuild doesn't change stripping behavior. (90% fail)
