Android Options > Linker properties > Linking Issue

axaaxa Member ✭✭✭
edited October 2018 in Xamarin.Android

I just got the error:
"System.MissingMemberException: The lazily-initialized type does not have a public, parameterless constructor."

This manifested when building for release and selecting the Linking 'Sdk and User Assemblies' option to reduce apk size.

Using RestSharp and attempting to replace the default RestRequest with that of a RestSharp.Serializers.Newtonsoft.Json.RestRequest
Specifically when attempting to initialize the Newtonsoft ResRequest, the exception gets thrown.

var restRequest = new RestSharp.Serializers.Newtonsoft.Json.RestRequest(method) { RequestFormat = DataFormat.Json, Timeout = _timeout, Resource = resource };

Apparently something is getting removed during the link optimization, so I tried to use the 'Skip Linking Assemblies' option adding the RestSharp assembly to the field but that didn't work.
So I needed to select the 'SDK Assemblies Only' option and my apk quadrupled in size :(

Its like the option just get ignored or i should be skipping another assembly that im not aware of...

I also tried using the attribute [Preserve(AllMembers = true)] on the class this all was in, to no avail.

Any thoughts?

Sign In or Register to comment.