Flutter, React Native & Unity

Unity Managed Stripping: Keep Reflective Entry Points Without Disabling Everything

Unity managed stripping removes code the linker considers unreachable. Reflection, serialization and runtime-selected types can require explicit preservation because their use may not be visible through ordinary static call analysis.

By Updated 2 min read

Find the dynamic contract

Start from the missing type or method and identify how it is reached. The managed-stripping guide describes supported preservation through attributes and link.xml.

Do not preserve every assembly before checking whether the library already provides the required annotations.

Preserve only the necessary surface

Runtime behavior Preservation question
Type loaded by name Must the type and its name remain?
Reflective constructor Which constructor is required?
Serialized member Which fields/properties are accessed?
Generic AOT path Is the needed instantiation available?

The IL2CPP documentation provides context for AOT constraints. A rule fixing one reflective path does not establish compatibility for every generic or runtime-generated path.

Test the stripped release

Development or editor execution may not exercise the same stripping pipeline. Build the intended release backend and test the exact feature that failed.

Include less frequent content paths, downloaded content where supported and error recovery. A type used only in a later level can remain invisible to a short smoke test.

Keep preservation maintainable

Document why each attribute or XML entry exists and which test protects it. Review old broad rules during dependency upgrades rather than accumulating permanent keep-all exceptions.

A smaller output is not a success if the game fails to deserialize a saved session.

Inspect with appropriate limits

APKLint's Unity Analyzer can help identify packaged assemblies/native structures, but it cannot simulate the linker's complete reachability model or run reflective code. Retain the build's stripping settings, preservation file and release test evidence. The desired result is a narrow, explainable rule that preserves functionality while allowing unrelated unused code to be removed.

Sources and further reading

  1. Unity: Managed code stripping
  2. Unity: IL2CPP

Reference review: 22 September 2026. Examples illustrate the workflow; check your installed versions, release artifact and account-specific Console requirements before applying them. This guide is not a claim that APKLint executed your project or verified your private account.

APKLint

Android inspection tools and practical release guides. About APKLint · Report a correction