JsonConvert.SerializeObject always return {} in XamarinForms

JsonConvert.SerializeObject seems to be not working in xamarin forms. Or i might be missing something here. Here is the output when i serialize a simple object. enter image description here

See it returns {}. I tried serializing a class also and it did return the same.

What could be the problem here?

UPDATE

Still no solution to this issue. I tried creating a simple console application and serializeObject is working on that project so i assume it is not working in xamarin forms only. Does anybody have a xamarin forms project where JSON.NET's serializeobject is working?

I am using visual studio 2017, json.net 10.0.3 and live player.


Solution 1:

This is a known problem see https://developer.xamarin.com/guides/cross-platform/live/limitations/

Limited support for reflection (currently affects some popular NuGets, like SQLite and Json.NET). Other NuGets are still supported.

If you compile it to an APK it works fine on the actual device.

Also posted an issue here: https://github.com/JamesNK/Newtonsoft.Json/issues/1578

Solution 2:

I tried setting up emulator on a fast machine and the serialize works! So it means it doesn't work when i run it on live player using my android phone. I will set this as an answer for now. if someone else posted on how to make it work on live player, i will set it as the correct answer