I'm using Xamarin.Forms and Application.Current.Properties to persist user settings. I'm testing it on Android and it works fine
But it doesn't work with linker configuration set to SDK Assemblies Only. I'm testing by deploying an APK file directly to the device. Then I try to enter some settings and restart the application - and after restart all settings are lost. I'm not using complex data types, only string and bool.
I've found a workaround suggested here: https://forums.xamarin.com/discussion/30723/problems-with-application-current-properties. It suggests to ignore Xamarin.Forms.Core assembly, but it doesn't help.
When linker configuration is set to None, the APK size is huge (50mb!). I want to avoid that.
How can I persist application properties in Release build without setting linker configuration to None? Is it a known Xamarin bug?
First of all, from xamarin docs(https://developer.xamarin.com/guides/xamarin-forms/working-with/application-class/#Properties_Dictionary) :
Note: the Properties dictionary can only serialize primitive types for storage. Attempting to store other types (such as List can fail silently).
If you want to store non-primitive type, you can, for example, convert it into JSON string using Newtonsoft.Json serializer, and then write to Properties(dont forget to deserialze when you read from Properties)
Btw, there is know bug: Properties didnt work in Release mode on Android. Suggest using Settings Plugin, it works pretty well.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With