c# - 构建后 Unity 游戏无法运行(MissingMethodException)

标签 c# unity3d

Unity 上的游戏可以运行,但是当我将其导出到 Android 时它停止运行。当我在终端中构建并运行时,出现以下错误:

2020/10/30 14:09:09.050 20499 20540 Error Unity MissingMethodException: Default constructor not found for type UnityEngine.ResourceManagement.AsyncOperations.ProviderOperation`1[[UnityEngine.AddressableAssets.Initialization.ResourceManagerRuntimeData, Unity.Addressables, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]]
2020/10/30 14:09:09.050 20499 20540 Error Unity   at System.RuntimeType.CreateInstanceMono (System.Boolean nonPublic) [0x00000] in <00000000000000000000000000000000>:0 
2020/10/30 14:09:09.050 20499 20540 Error Unity   at System.Activator.CreateInstance (System.Type type, System.Boolean nonPublic) [0x00000] in <00000000000000000000000000000000>:0 
2020/10/30 14:09:09.050 20499 20540 Error Unity   at UnityEngine.ResourceManagement.Util.LRUCacheAllocationStrategy.New (System.Type type, System.Int32 typeHash) [0x00000] in <00000000000000000000000000000000>:0 
2020/10/30 14:09:09.050 20499 20540 Error Unity   at UnityEngine.ResourceManagement.ResourceManager.CreateOperation[T] (System.Type actualType, System.Int32 typeHash, System.Int32 operationHash, System.Action`1[T] onDestroyAction) [0x00000] in <00000000000000000000000000000000>:0 
2020/10/30 14:09:09.050 20499 20540 Error Unity   at UnityEngine.ResourceManagement.ResourceManager.ProvideResource (UnityEngine.ResourceM
2020/10/30 14:09:09.057 20499 20540 Error Unity MissingMethodException: Default constructor not found for type UnityEngine.ResourceManagement.ResourceManager+CompletedOperation`1[[System.Collections.Generic.IList`1[[ThemeData, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]
2020/10/30 14:09:09.057 20499 20540 Error Unity   at System.RuntimeType.CreateInstanceMono (System.Boolean nonPublic) [0x00000] in <00000000000000000000000000000000>:0 
2020/10/30 14:09:09.057 20499 20540 Error Unity   at System.Activator.CreateInstance (System.Type type, System.Boolean nonPublic) [0x00000] in <00000000000000000000000000000000>:0 
2020/10/30 14:09:09.057 20499 20540 Error Unity   at UnityEngine.ResourceManagement.Util.LRUCacheAllocationStrategy.New (System.Type type, System.Int32 typeHash) [0x00000] in <00000000000000000000000000000000>:0 
2020/10/30 14:09:09.057 20499 20540 Error Unity   at UnityEngine.ResourceManagement.ResourceManager.CreateOperation[T] (System.Type actualType, System.Int32 typeHash, System.Int32 operationHash, System.Action`1[T] onDestroyAction) [0x00000] in <00000000000000000000000000000000>:0 
2020/10/30 14:09:09.057 20499 20540 Error Unity   at UnityEngine.ResourceManagement.Res

最佳答案

一切都与代码剥离有关。如果你想快速解决,你可以在 Assets 文件夹中创建 link.xml 文件,内容如下:

<linker>
    <assembly fullname="Unity.ResourceManager" preserve="all" />
    <assembly fullname="Unity.Addressables" preserve="all" />
</linker>

如果您不使用 Addressables,下一个代码:

<linker>
    <assembly fullname="Unity.ResourceManager" preserve="all" />
</linker>

您还可以制定更严格的代码剥离规则。更多关于代码剥离的信息你可以找到by this link .

关于c# - 构建后 Unity 游戏无法运行(MissingMethodException),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64609096/

相关文章:

c# - 如何使用nearSphere mongodb驱动程序c#返回从点到点的距离结果

c# - EPPlus 导出模型到 Excel : System. NullReferenceException

c# - 在Unity中序列化和反序列化Json和Json数组

c# - Photon Networking Unity AllProperties 未设置

c# - 有没有办法检测用户是否正在编辑属性网格中的属性?

c# - 何时使用泛型和类型检查?

c# - AngleSharp OpenAsync 返回空体

unity3d - 如何将文件写入 Oculus Quest 内部存储

c# - 当手靠近/远离 HoloLens 相机时,将游戏对象移近/远离 HoloLens 相机

c# - WWW WebRequest UriFormatException : URI scheme must start with a letter and must consist of one of