Unity2021.3.4f1使用WeRequest.Create在Android下导致异常

记录一个Bug:

Unity2021.3.4f1,使用WeRequest.Create,使用mono打包,Unity Editor及WIndows平台中正常,在安卓平台就会抛出异常

System.NullReferenceException: Object reference not set to an instance of an object
  at System.Net.WebRequestPrefixElement..ctor (System.String P, System.Type creatorType) [0x00018] in <3a0cdb6ab18d4d64a4156144c783ac1e>:0 
  at System.Net.WebRequest.PopulatePrefixList () [0x00040] in <3a0cdb6ab18d4d64a4156144c783ac1e>:0 
  at System.Net.WebRequest.get_PrefixList () [0x00022] in <3a0cdb6ab18d4d64a4156144c783ac1e>:0 
  at System.Net.WebRequest.Create (System.Uri requestUri, System.Boolean useUriBase) [0x0002e] in <3a0cdb6ab18d4d64a4156144c783ac1e>:0 
  at System.Net.WebRequest.Create (System.String requestUriString) [0x00014] in <3a0cdb6ab18d4d64a4156144c783ac1e>:0 

太坑了,这么重要的网络库,居然会有bug,unity自己都不测的吗。。。
解决方案:使用il2cpp打包,或者是升级到2021.3.11f1 以上的版本
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/weixin_42562717/article/details/129745842