C# – xamarin.forms property is not saved in Android version

I'm using xamarin. Forms and application. Current. Properties to persist user settings. I tested it on Android and it worked properly

>In debug mode > in release mode, the linker configuration is set to none

But it doesn't apply to linker configurations that are only set to SDK assemblies. I'm testing by deploying APK files directly to the device. Then I try to enter some settings and restart the application - all settings will be lost after restart. I don't use complex data types, only strings and bool

I found a solution here: https://forums.xamarin.com/discussion/30723/problems-with-application-current-properties. It recommends ignoring the xamarin. Forms. Core assembly, but it does not help

When the linker configuration is set to none, the APK size is very large (50MB!). I want to avoid this situation

How do I keep application properties in the release version without setting the linker configuration to none? Is this a known xamarin bug?

resolvent:

First, from xamarin docs( https://developer.xamarin.com/guides/xamarin-forms/working-with/application-class/#Properties_Dictionary ):

If you want to store a non basic type, you can use the newtonsoft. JSON serializer to convert it to a JSON string and write the property (don't forget to deserialize when you read from the property)

By the way, I know the error: the attribute is invalid in the publishing mode on Android. It is recommended to use settings plugin, which works well

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>