Unity Firebase 存储 Mscorlib 剥离
Unity Firebase Storage Mscorlib Stripping
我一直在为 Unity 使用 firebase,我知道它仍处于实验阶段。
构建 APK 并将剥离级别设置为 Mscorlib 时,逻辑上出现错误,阻止 uploading/downloading 存储
这里是错误
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 中工作,是否真的有必要将剥离级别设置为禁用?
您应该将 IL2CPP 与 iOS 一起使用,它始终打开字节级剥离。实际上没有办法用 IL2CPP 关闭字节剥离。参见 https://docs.unity3d.com/Manual/iphone-playerSizeOptimization.html。字节级剥离 应该 与 Firebase 存储一起使用。
如果您出于某种原因不使用 IL2CPP,那么直接回答您的问题,您不能将 micro-mscorlib 与 Firebase 存储一起使用,因为 Firebase 存储需要 .Net 的某些功能。您应该能够使用其他选项(字节或模块级别)。
使用字节级剥离(无论是否使用 IL2CPP)时,您不需要指定 link.xml 文件,因为 unity 应该能够推断每个 class 的用法。
--编辑--
在我们即将发布的版本中,我们修复了字节和汇编级字节剥离。如果您想尝试一种解决方法,需要几个额外的 link.xml 条目来防止 unity 剥离使用过的 classes。这些条目在下面并将自动添加到我们的下一个 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>
我一直在为 Unity 使用 firebase,我知道它仍处于实验阶段。
构建 APK 并将剥离级别设置为 Mscorlib 时,逻辑上出现错误,阻止 uploading/downloading 存储
这里是错误
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 中工作,是否真的有必要将剥离级别设置为禁用?
您应该将 IL2CPP 与 iOS 一起使用,它始终打开字节级剥离。实际上没有办法用 IL2CPP 关闭字节剥离。参见 https://docs.unity3d.com/Manual/iphone-playerSizeOptimization.html。字节级剥离 应该 与 Firebase 存储一起使用。
如果您出于某种原因不使用 IL2CPP,那么直接回答您的问题,您不能将 micro-mscorlib 与 Firebase 存储一起使用,因为 Firebase 存储需要 .Net 的某些功能。您应该能够使用其他选项(字节或模块级别)。
使用字节级剥离(无论是否使用 IL2CPP)时,您不需要指定 link.xml 文件,因为 unity 应该能够推断每个 class 的用法。
--编辑-- 在我们即将发布的版本中,我们修复了字节和汇编级字节剥离。如果您想尝试一种解决方法,需要几个额外的 link.xml 条目来防止 unity 剥离使用过的 classes。这些条目在下面并将自动添加到我们的下一个 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>