Unity打Android包异常

2022/12 03 20:12

A工程在出Android包时,出以下错误:

Exception: C:\Program Files\Unity\Hub\Editor\2019.4.38f1\Editor\Data\il2cpp\build/deploy/net471/UnityLinker.exe did not run properly!

Failed running "C:\Program Files\Unity\Hub\Editor\2019.4.38f1\Editor\Data\il2cpp\build/deploy/net471/UnityLinker.exe" @D:/depot/uwproj/develop/client/UWGame/Temp/StagingArea/assets/bin/Data/Managed/response.rsp 

stdout:
Fatal error in Unity CIL Linker
System.ArgumentException: ??????????????????
   ?? System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
   ?? System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
   ?? Unity.Linker.EngineStripping.EngineModuleResolver.Initialize(UnityLinkContext context, AssemblyDefinition unityEngineFacade, ModulesAssetFile modulesAssetFile)
   ?? Unity.Linker.EngineStripping.EngineStrippingContext.Initialize(AssemblyDefinition unityEngineFacade)
   ?? Unity.Linker.Steps.InitializeEngineStrippingStep.Process()
   ?? Mono.Linker.Steps.BaseStep.Process(LinkContext context)
   ?? Mono.Linker.Pipeline.ProcessStep(LinkContext context, IStep step)
   ?? Unity.Linker.UnityPipeline.ProcessStep(LinkContext context, IStep step)
   ?? Mono.Linker.Pipeline.Process(LinkContext context)
   ?? Unity.Linker.UnityDriver.Run()
   ?? Unity.Linker.UnityDriver.RunDriverWithoutErrorHandling()
   ?? Unity.Linker.UnityDriver.RunDriver()
stderr:

UnityEditorInternal.Runner.RunProgram (UnityEditor.Utils.Program p, System.String exe, System.String args, System.String workingDirectory, UnityEditor.Scripting.Compilers.CompilerOutputParserBase parser) (at <20984e470d9848a29f910d0b91cc5402>:0)
UnityEditorInternal.Runner.RunManagedProgram (System.String exe, System.String args, System.String workingDirectory, UnityEditor.Scripting.Compilers.CompilerOutputParserBase parser, System.Action`1[T] setupStartInfo) (at <20984e470d9848a29f910d0b91cc5402>:0)
UnityEditorInternal.AssemblyStripper.RunAssemblyLinker (System.Collections.Generic.IEnumerable`1[T] args, System.String& out, System.String& err, System.String linkerPath, System.String workingDirectory) (at <20984e470d9848a29f910d0b91cc5402>:0)
UnityEditorInternal.AssemblyStripper.StripAssembliesTo (System.String outputFolder, System.String& output, System.String& error, System.Collections.Generic.IEnumerable`1[T] linkXmlFiles, UnityEditorInternal.UnityLinkerRunInformation runInformation) (at <20984e470d9848a29f910d0b91cc5402>:0)
UnityEditorInternal.AssemblyStripper.RunAssemblyStripper (UnityEditorInternal.UnityLinkerRunInformation runInformation) (at <20984e470d9848a29f910d0b91cc5402>:0)
UnityEditorInternal.AssemblyStripper.StripAssemblies (System.String managedAssemblyFolderPath, UnityEditorInternal.BaseUnityLinkerPlatformProvider unityLinkerPlatformProvider, UnityEditorInternal.IIl2CppPlatformProvider il2cppPlatformProvider, UnityEditor.RuntimeClassRegistry rcr, UnityEditor.ManagedStrippingLevel managedStrippingLevel) (at <20984e470d9848a29f910d0b91cc5402>:0)
UnityEditorInternal.IL2CPPBuilder.Run () (at <20984e470d9848a29f910d0b91cc5402>:0)
UnityEditorInternal.IL2CPPUtils.RunIl2Cpp (System.String tempFolder, System.String stagingAreaData, UnityEditorInternal.IIl2CppPlatformProvider platformProvider, System.Action`1[T] modifyOutputBeforeCompile, UnityEditor.RuntimeClassRegistry runtimeClassRegistry) (at <20984e470d9848a29f910d0b91cc5402>:0)
UnityEditor.Android.PostProcessor.Tasks.RunIl2Cpp.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <b0b2e60bb77549c6b5ce993fd741c713>:0)
UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <b0b2e60bb77549c6b5ce993fd741c713>:0)
UnityEditor.Android.PostProcessAndroidPlayer.PostProcess (UnityEditor.BuildTarget target, System.String stagingAreaData, System.String stagingArea, System.String playerPackage, System.String installPath, System.String companyName, System.String productName, UnityEditor.BuildOptions options, UnityEditor.RuntimeClassRegistry usedClassRegistry, UnityEditor.Build.Reporting.BuildReport report) (at <b0b2e60bb77549c6b5ce993fd741c713>:0)
UnityEditor.Android.AndroidBuildPostprocessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args, UnityEditor.BuildProperties& outProperties) (at <b0b2e60bb77549c6b5ce993fd741c713>:0)
UnityEditor.PostprocessBuildPlayer.Postprocess (UnityEditor.BuildTargetGroup targetGroup, UnityEditor.BuildTarget target, 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 <20984e470d9848a29f910d0b91cc5402>:0)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)

1、A工程:删除Library,重开Unity,出错

2、新建一个空工程:B工程,打Android包,正常

3、A工程:由IL2CPP切到Mono模式,正常

4、A工程:把Unity2019.4.38f1切换到2019.4.40f1,出错

5、把整个工程全部删光,全部拉新工程,重开Unity,正常