JsonConvert.DeserializeObject doesn't work in Release mode (Android only)

Hi,

I have a very strange problem deserializing object from json string.

Everything works good in debug mode, but not in release with the same data. The strangest part is that I use it in several places - one is generic call, and it works, the second one is parsing of the exact object (failing one). I guess it something with linker. If to set linker mode to "none" it resolves the problem, but almost 50 MB apk is not acceptable... I used "link SDK assemblies only" and tried to add almost every assembly to "linking ignore list", nothing helps. If needed I can make simple repro project.

Anton

Tagged:

Posts

  • Amar_BaitAmar_Bait DZMember ✭✭✭✭✭

    Did you add Json.net to both PCL and Android project?

  • yes sure. json.net nuget package (6.0.8) is added to every project

  • it was System.Runtime... adding it to linking ignore resolved the problem

  • JamesScottJamesScott USMember ✭✭

    This DID NOT work for me... Any other ideas Xamarin? I'm losing it over here.... Lost a whole afternoon trying different ideas mentioned on different posts, none of them work. Please help!

  • Felix.xFelix.x USMember ✭✭

    You need to put the [Preserve(AllMembers = true)] attribute on any classes that are dynamically generated. This will prevent them from being stripped out.

    https://stackoverflow.com/a/37123169/75947

Sign In or Register to comment.