Newtonsoft.Json 在安卓上报错

Markdown
System.PlatformNotSupportedException: Operation is not supported on this platform.at System.Reflection.Emit.DynamicMethod…ctor (System.String name, System.Type returnType, System.Type]] parameterTypes, System.Type owner,System.Boolean skipVisibility) [Ox00000] in <00000000000000000000000000000000>:0
at Newtonsoft.Json.Utilities.DynamicReflectionDelegateFactory.CreateDynamicMethod (System.String name, System.Type returnType, System.Type]lparameterTypes, System.Type owner) [0x00000] in <00000000000000000000000000000000>:0
at Newtonsoft.Json.Utilities.DynamicReflectionDelegateFactory.CreateDefaultConstructor[T] (System.Type type) [Ox00000] in<0000000000000000000>:0
at Newtonsoft.Json.Serialization.DefaultContractResolver.InitializeContract (Newtonsoft.Json.Serialization.JsonContract contract) [Oxo0000] in
007:0
at Newtonsoft.Json.Serialization.DefaultContractResolver.CreateObjectContract (System.Type objectType) [Ox00000] in
at Newtonsoft.Json.Utilities.ThreadSafeStore 2[TKey,TValue].AddValue (TKey key) [Ox00000] in <0000000000000
000>:0
at Newtonsoft.Json.Utilities.ThreadSafeStore 2[TKey,TValue].Get (TKey key) [Ox00000] in <00000000
0>:0
at Newtonsoft.Json.Serialization.JsonSerializerinternalWriter.Serialize (Newtonsoft.Json.JsonWriter jsonWriter, System.Object value, System.TypelobjectType) [0x00000] in <0000000000000>:0at Newtonsoft.Json.JsonSerializer.SerializeInternal (Newtonsoft.Json.JsonWriter jsonWriter, System.Object value, System.Type objectType) [Ox00000] in
n:0
at Newtonsoft.Json.JsonConvert.SerializeObjectInternal (System.Object value, System.Type type, Newtonsoft.Json.JsonSerializer jsonSerializer)[Ox00000] in <0000000000>:

unity上使用 Newtonsoft.Json 序列化不报错,打安卓包运行就报这个错

解决办法:
在这里插入图片描述

设置中修改 Api Compatibility Level

使用官方的 json 库,不要用 Newtonsoft.Json.dll,通过 Package Manager 安装 com.unity.nuget.newtonsoft-json

  • 6
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值