开发者社区 > 云存储 > 对象存储OSS > 正文

导入最新的Aliyun.OSS.dll,Unity2020编辑器运行正常,android运行报错

已解决

1.导入最新的Aliyun.OSS.dll
2.将Unity-Player-Other Settings设置
Api Compatibillity Level* = .NET 4.X
企业微信截图_16980590261609.png
编辑器下运行正常
企业微信截图_16980590698071.png

3.导出android包以后,运行报错
2023-10-23 18:57:24.372 29533-29619/? D/xiaoyuan: getUpdateCycle start
2023-10-23 18:57:24.378 29426-29730/? I/Unity: -----------------下载文件出错:System.NullReferenceException: Object reference not set to an instance of an object.
at Aliyun.OSS.Common.Communication.HttpExtensions.AddInternal (System.Net.WebHeaderCollection headers, System.String key, System.String value) [0x00000] in <00000000000000000000000000000000>:0
at Aliyun.OSS.Common.Communication.HttpFactory.SetRequestHeaders (System.Net.HttpWebRequest webRequest, Aliyun.OSS.Common.Communication.ServiceRequest serviceRequest, Aliyun.OSS.Common.ClientConfiguration configuration) [0x00000] in <00000000000000000000000000000000>:0
at Aliyun.OSS.Common.Communication.HttpFactory.CreateWebRequest (Aliyun.OSS.Common.Communication.ServiceRequest serviceRequest, Aliyun.OSS.Common.ClientConfiguration configuration) [0x00000] in <00000000000000000000000000000000>:0
at Aliyun.OSS.Common.Communication.ServiceClientImpl.SendCore (Aliyun.OSS.Common.Communication.ServiceRequest serviceRequest, Aliyun.OSS.Common.Communication.ExecutionContext context) [0x00000] i
2023-10-23 18:57:24.392 1553-2442/? D/GameManagerService: respondWithJson. command: get_sysfs_data

展开
收起
啊蹦蹦 2023-10-23 19:08:40 155 0
1 条回答
写回答
取消 提交回答
  • 采纳回答

    原因:
    1.通过查看源码增加打印测试得知,在android环境中,Environment.OSVersion.Platform识别成了
    Environment.OSVersion.Platform=PlatformID.Unix;
    最后导致
    _isMonoPlatform = MonoPlatforms.Contains(Environment.OSVersion.Platform);
    _isMonoPlatform = true;
    后续的赋值导致_addInternalMethod = null;
    企业微信截图_16982042452288.png

    解决方案:
    1.注释HttpExtensions.MonoPlatforms变量中的PlatformID.Unix
    企业微信截图_16982044013076.png
    2.选中 aliyun-oss-sdk项目重新生成dll
    3.拷贝 D:\unityWork\aliyun-oss-csharp-sdk-2.13.0\sdk\bin\Debug\Aliyun.OSS.dll覆盖到项目中
    4.出android包测试成功

    2023-10-25 11:33:19
    赞同 展开评论 打赏

相关产品

  • 对象存储
  • 热门讨论

    热门文章

    相关电子书

    更多
    OSS运维进阶实战手册 立即下载
    《OSS运维基础实战手册》 立即下载
    OSS运维基础实战手册 立即下载