首页 文章

Unity Firebase存储Mscorlib剥离

提问于
浏览
0

我一直在为Unity使用firebase,我知道它仍然是实验性的 .

构建APK并将剥离级别设置为Mscorlib时,会出现逻辑上的错误,导致无法上载/下载到存储

这是错误

NotSupportedException: ..... etc.
    System.Net.WebRequest.GetCreator (System.String prefix) [0x00000]in <filename unknown>:0 
    I/Unity   (16919):   at System.Net.WebRequest.Create (System.Uri requestUri) [0x00000] in <filename unknown>:0 
    I/Unity   (16919):   at Firebase.UnityHttpRequest+<SendUnityRequest>c__Iterator0.MoveNext () [0x00000] in <filename unknown>:0

但是当设置为Disabled时就可以了 . 但我需要这个来减少文件大小 . 我使用了linker.xml来保存“System.Net.HttpRequestCreator”,但我相信这只适用于iOS?

我的问题是,是否真的有必要设置剥离级别以禁用firebase存储在Unity中工作?

1 回答

  • 0

    你应该在iOS上使用IL2CPP,它总是打开字节级剥离 . 实际上没有办法用IL2CPP关闭字节剥离 . 见https://docs.unity3d.com/Manual/iphone-playerSizeOptimization.html . 字节级别剥离应与Firebase存储一起使用 .

    如果您由于某种原因未使用IL2CPP,那么直接回答您的问题,您不能将micro-mscorlib与Firebase存储一起使用,因为Firebase存储需要.Net的某些功能 . 您应该能够使用其他选项(字节或模块级别) .

    当使用字节级剥离(或不使用IL2CPP)时,您不需要指定link.xml文件,因为unity应该能够推断每个类的使用情况 .

    --EDIT--在我们即将发布的版本中,我们修复了字节和汇编级字节剥离 . 如果您想尝试一种解决方法,则需要几个额外的link.xml条目来防止统一剥离已使用的类 . 这些条目如下,将自动添加到我们的下一个SDK版本中 .

    <assembly fullname="mscorlib">
      <namespace fullname="Mono.Security.Cryptography" preserve="all"/>
      <namespace fullname="System.Security" preserve="all"/>
      <namespace fullname="System.Security.Cryptography" preserve="all" />
      <namespace fullname="System.Security.Cryptography.X509Certificates" preserve="all" />
    </assembly>
    <assembly fullname="Mono.Security">
      <namespace fullname="Mono.Security.Protocol.Tls" preserve="all"/>
      <namespace fullname="Mono.Security.X509" preserve="all"/>
    </assembly>
    <assembly fullname="System">
      <namespace fullname="System" preserve="all"/>
      <namespace fullname="System.ComponentModel" preserve="all"/>
      <namespace fullname="System.ComponentModel.EnumConverter" preserve="all"/>
      <namespace fullname="System.Configuration" preserve="all"/>
      <namespace fullname="System.Net" preserve="all"/>
      <namespace fullname="System.Net.Configuration" preserve="all"/>
      <namespace fullname="System.Net.NetworkInformation" preserve="all"/>
      <namespace fullname="System.Net.Sockets" preserve="all"/>
      <namespace fullname="System.Net.Security" preserve="all"/>
      <namespace fullname="System.Runtime.ConstrainedExecution" preserve="all"/>
      <namespace fullname="System.Runtime.InteropServices" preserve="all"/>
      <namespace fullname="System.Runtime.Serialization" preserve="all"/>
      <namespace fullname="System.Security.Cryptography" preserve="all" />
      <namespace fullname="System.Security.Cryptography.X509Certificates" preserve="all" />
    </assembly>
    <assembly fullname="System.Core">
      <namespace fullname="System.Security.Cryptography" preserve="all" />
    </assembly>
    <assembly fullname="System.Configuration">
      <namespace fullname="System.Configuration" preserve="all" />
    </assembly>
    

相关问题