unity build_error ai_generated partial

IL2CPP error: Unity.IL2CPP.Building.BuilderFailedException: Attempting to constrain an unconstructed type

ID: unity/il2cpp-build-error

Also available as: JSON · Markdown
75%Fix Rate
83%Confidence
3Evidence
2023-01-01First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
2022 active
2022 active

Root Cause

IL2CPP AOT compilation failed. Generic type stripping, reflection usage, or unsupported managed code pattern.

generic

Workarounds

  1. 88% success Add a link.xml to preserve types stripped by IL2CPP linker
    <linker><assembly fullname="MyAssembly" preserve="all"/></linker>  # in Assets/link.xml

    Sources: https://docs.unity3d.com/Manual/upm-ui.html

  2. 82% success Add dummy references for generic types used via reflection
    private void PreserveTypes() { new List<MyType>(); }  // forces IL2CPP to generate code for this generic
  3. 78% success Update IL2CPP / Unity to latest patch for bug fixes
    Unity Hub > Installs > Check for Updates; IL2CPP bugs are fixed frequently in patch releases

Dead Ends

Common approaches that don't work:

  1. Switch to Mono backend to avoid IL2CPP issues 78% fail

    Mono is not available on iOS/consoles. IL2CPP is mandatory for most release platforms.

  2. Disable code stripping entirely 72% fail

    Disabling stripping includes everything, making builds 2-5x larger. Use a link.xml instead.