You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Unity升级至2021.3.4f1编辑器后无法完成Android应用构建

问题描述

将Unity编辑器升级到2021.3.4f1版本后,构建Android应用时出现构建失败问题,报错信息如下:

Building Library\Bee\artifacts\Android\ManagedStripped failed with output:

C:\Program Files\Unity\Hub\Editor\2021.3.4f1\Editor\Data\il2cpp\build\deploy\UnityLinker.exe --search-directory=C:/Users/DELL/Documents/MEGAsync Downloads/TRAFFIC.IO/Traf/Temp/StagingArea/Data/Managed --out=Library/Bee/artifacts/Android/ManagedStripped --include-link-xml=C:/Users/DELL/Documents/MEGAsync Downloads/TRAFFIC.IO/Traf/Temp/StagingArea/Data/Managed\MethodsToPreserve.xml --include-link-xml=C:/Users/DELL/Documents/MEGAsync Downloads/TRAFFIC.IO/Traf/Temp/StagingArea/Data/Managed\TypesInScenes.xml --include-link-xml=C:/Users/DELL/Documents/MEGAsync Downloads/TRAFFIC.IO/Traf/Temp/StagingArea/Data/Managed\SerializedTypes.xml --include-link-xml=C:\Users\DELL\Documents\MEGAsync Downloads\TRAFFIC.IO\Traf\Temp\burst.link.xml --include-link-xml=C:\Users\DELL\Documents\MEGAsync Downloads\TRAFFIC.IO\Traf\Assets\UnityAds\link.xml --include-link-xml=C:/Program Files/Unity/Hub/Editor/2021.3.4f1/Editor/Data/PlaybackEngines/AndroidPlayer/Tools/AndroidNativeLink.xml --include-directory=C:/Users/DELL/Documents/MEGAsync Downloads/TRAFFIC.IO/Traf/Temp/StagingArea/Data/Managed --dotnetprofile=unityaot-linux --dotnetruntime=Il2Cpp --platform=Android --use-editor-options --enable-engine-module-stripping --engine-modules-asset-file=C:/Program Files/Unity/Hub/Editor/2021.3.4f1/Editor/Data/PlaybackEngines/AndroidPlayer/modules.asset --editor-data-file=C:/Users/DELL/Documents/MEGAsync Downloads/TRAFFIC.IO/Traf/Temp/StagingArea/Data/Managed/EditorToUnityLinkerData.json --include-unity-root-assembly=C:/Users/DELL/Documents/MEGAsync Downloads/TRAFFIC.IO/Traf/Temp/StagingArea/Data/Managed/Assembly-CSharp.dll --include-unity-root-assembly=C:/Users/DELL/Documents/MEGAsync Downloads/TRAFFIC.IO/Traf/Temp/StagingArea/Data/Managed/ToonyColorsPro2.Demo.dll --include-unity-root-assembly=C:/Users/DELL/Documents/MEGAsync Downloads/TRAFFIC.IO/Traf/Temp/StagingArea/Data/Managed/KinoBloom.Runtime.dll --include-unity-root-assembly=C:/Users/DELL/Documents/MEGAsync Downloads/TRAFFIC.IO/Traf/Temp/StagingArea/Data/Managed/Unity.RenderPipelines.Core.Runtime.dll --include-unity-root-assembly=C:/Users/DELL/Documents/MEGAsync Downloads/TRAFFIC.IO/Traf/Temp/StagingArea/Data/Managed/UnityEngine.UI.dll --include-unity-root-assembly=C:/Users/DELL/Documents/MEGAsync Downloads/TRAFFIC.IO/Traf/Temp/StagingArea/Data/Managed/ToonyColorsPro.Runtime.dll --include-unity-root-assembly=C:/Users/DELL/Documents/MEGAsync Downloads/TRAFFIC.IO/Traf/Temp/StagingArea/Data/Managed/TextMeshPro-2017.3-Runtime.dll --print-command-line

Fatal error in Unity CIL Linker

Mono.Linker.LinkerFatalErrorException: ILLink: error IL1005: TMPro.TMP_InputField.CreateCursorVerts(): Error processing method 'TMPro.TMP_InputField.CreateCursorVerts()' in assembly 'TextMeshPro-2017.3-Runtime.dll'

 ---> Mono.Cecil.ResolutionException: Failed to resolve UnityEngine.Vector2 UnityEngine.UIVertex::uv0

   at Mono.Linker.Steps.MarkStep.HandleUnresolvedField(FieldReference reference)

   at Mono.Linker.Steps.MarkStep.MarkField(FieldReference reference, DependencyInfo reason)

   at Mono.Linker.Steps.MarkStep.MarkInstruction(Instruction instruction, MethodDefinition method, Boolean& requiresReflectionMethodBodyScanner)

   at Mono.Linker.Steps.MarkStep.MarkMethodBody(MethodBody body)

   at Unity.Linker.Steps.UnityMarkStep.MarkMethodBody(MethodBody body)

   at Mono.Linker.Steps.MarkStep.ProcessMethod(MethodDefinition method, DependencyInfo& reason)

   at Unity.Linker.Steps.UnityMarkStep.ProcessMethod(MethodDefinition method, DependencyInfo& reason)

   at Mono.Linker.Steps.MarkStep.ProcessQueue()

   --- End of inner exception stack trace ---

   at Mono.Linker.Steps.MarkStep.ProcessQueue()

   at Mono.Linker.Steps.MarkStep.ProcessPrimaryQueue()

   at Mono.Linker.Steps.MarkStep.Process()

   at Mono.Linker.Steps.MarkStep.Process(LinkContext context)

   at Unity.Linker.Steps.UnityMarkStep.Process(LinkContext context)

   at Unity.Linker.UnityPipeline.ProcessStep(LinkContext context, IStep step)

   at Mono.Linker.Pipeline.Process(LinkContext context)

   at Unity.Linker.UnityDriver.UnityRun(Boolean noProfilerAllowed, ILogger customLogger)

   at Unity.Linker.UnityDriver.RunDriverWithoutErrorHandling(ILogger customLogger, Boolean noProfilerAllowed)

   at Unity.Linker.UnityDriver.RunDriver()

UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)

BuildFailedException: 增量播放器构建失败!
UnityEditor.Modules.BeeBuildPostprocessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args) (at <36f62d8e760b48f7af5d32916f997ce1>:0)
UnityEditor.Modules.DefaultBuildPostprocessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args, UnityEditor.BuildProperties& outProperties) (at <36f62d8e760b48f7af5d32916f997ce1>:0)
UnityEditor.Android.AndroidBuildPostprocessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args, UnityEditor.BuildProperties& outProperties) (at :0)
UnityEditor.PostprocessBuildPlayer.Postprocess (UnityEditor.BuildTargetGroup targetGroup, UnityEditor.BuildTarget target, System.Int32 subtarget, System.String installPath, System.String companyName, System.String productName, System.Int32 width, System.Int32 height, UnityEditor.BuildOptions options, UnityEditor.RuntimeClassRegistry usedClassRegistry, UnityEditor.Build.Reporting.BuildReport report) (at <36f62d8e760b48f7af5d32916f997ce1>:0)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)

报错原因

核心触发点是项目内手动导入的2017.3版本TextMeshPro版本过旧,与Unity 2021.3内置API不兼容。旧版TMP中TMP_InputField.CreateCursorVerts()方法引用了UnityEngine.UIVertex结构的uv0字段,该字段在Unity 2021.x版本中已做调整,IL2CPP构建的代码裁剪阶段无法找到对应字段引用,直接触发Unity CIL链接器致命错误,最终导致构建失败。

解决方法

按以下顺序操作,优先使用长期方案:

  • 彻底删除项目中手动导入的旧版TextMeshPro全量文件夹,重点排查并删除残留的TextMeshPro-2017.3-Runtime.dll文件
  • 打开Unity顶部菜单Window > Package Manager,在包列表中找到TextMeshPro,安装适配Unity 2021.3的官方内置版本,安装完成后按弹窗提示导入TMP基础运行资源
  • 若删除旧版TMP后出现预制体、脚本引用丢失,将丢失引用重新指向新安装的内置TMP对应类即可,两个版本API差异极小,基本无需修改业务逻辑
  • 临时应急方案:若暂时无法替换TMP版本,打开Player Settings > Other Settings,将Managed Stripping Level(托管代码裁剪级别)调整为Low,关闭高等级代码裁剪即可绕过该报错。该方案会增大安装包体积,不建议长期使用
  • 所有修改完成后,关闭Unity编辑器,删除项目根目录下的Library、Temp缓存文件夹,重新打开项目执行Android构建即可

内容的提问来源于stack exchange,提问作者Chawkii

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.29 00:39:45