【问题标题】:Unity game not working after build (MissingMethodException)Unity 游戏在构建后无法运行(MissingMethodException)
【发布时间】:2021-09-30 21:46:16
【问题描述】:

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

【问题讨论】:

  • 你有最新的安卓操作系统吗?我检查了类似的问题,发现了一个 2019 年初的问题,所以我怀疑您可能使用的是旧版本的 Android。
  • @jdweng 是的Android系统更新到最新版本,unity版本也更新了(2020.1.0f1)。有问题的游戏是EndlessRunner,它是由unity制作的开源游戏。如果您想查看,请点击以下链接:github.com/Unity-Technologies/EndlessRunnerSampleGame
  • Android 运行在手机/设备内核之上,内核可能较旧。
  • 这可能与装配剥离有关吗?例如。您正在通过编译时未知的动态类型使用某些东西?
  • @derHugo 不,我不使用任何动态输入

标签: c# unity3d


【解决方案1】:

这都是关于代码剥离的。如果你想要快速解析,你可以在 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

【讨论】:

    【解决方案2】:

    如果您发现本地化包在构建中不起作用,请尝试以下操作:

    1. 更新到最新的 Unity 补丁版本
    2. 在包管理器中更新到最新的 Addressable Assets 包。
    3. 尝试禁用代码剥离
    4. 清理和重建可寻址对象。构建时,请确保在构建设置窗口中将编辑器设置为目标平台。
    5. 尝试运行本地化分析器(0.11.0-preview)。这可以在 Addressables 窗口中找到。 Link

    Reference

    https://forum.unity.com/threads/troubleshooting-addressables-issues.1060346/

    1:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-12-16
      • 2015-10-13
      • 2022-12-01
      相关资源
      最近更新 更多