The example shows how to preserve single types. But apparently you can also preserve whole namespaces at a time with namespace-tag. How about wildcards for preserving a set of namespaces? E.g. specifying “System.Net.*” or something similar.
I’d like to know this, too. It seems very hard to find details on setting up link.xml
We’ve found that stripping causes problems with both the Parse and GameSparks plug-ins - and I’m looking for the best way to fix it (without turning stripping off entirely).
Well, link.xml just gives a list of Classes that you don’t want stripped. As the docs show, it’s a list of assemblies, with the must-keep-at-all-cost Classes each contains.
Obviously, what’s hard to working out what Classes code that you did not write depend on. The docs recommend running your code on the emulator and seeing what causes it to crash. I know that’s messy.
After a bit of trial-and-error/process-of-elimination, I managed to fix our GameSparks plugin problem with this link.xml:
<linker>
<!-- This fixes GameSparks 'ERROR: The authentication
or decryption has failed' errors when stripping is enabled -->
<assembly fullname="mscorlib">
<type fullname="System.Security.Cryptography.*" preserve="all"/>
</assembly>
</linker>
I started by looking inside a stripped and unstripped Android .apk, to see which .dll’s where there and which were significantly stripped - and added them all to the link.xml, basically preventing it stripping everything. Once that worked, I started narrowing it down until I was just left with a single assembly, and looked for anything related to the specific problem (the code was running, but giving an error message)
As for the syntax, something that wasn’t clear was whether wildcards where supported - actually, I’m not sure if the ‘.*’ was needed here, or if just ‘System.Security.Cryptography’ would have been included without - I’d seen it in somebody else’s example/attempt, so put that in.
Also, I’d seen this - Parse Platform - and the assembly name of ‘Parse.Unity’ added to the confusion…
Does anyone know how to specify generic type definitions in a link.xml file? When the generic type parameter is a struct type, I need to be sure to compile in definitions for each struct type.
We are having this problem too. For List you can just add a dummy function that calls new List(); or whatever.
Unfortunately, I have a missing generic type that is in Newtonsoft Json for Unity which is private
Also in this boat. @Graham-Dunnett , is there any way of specifying generic types (either closed-constructed or open-constructed) in the link.xml file? The Documentation page doesn’t show any example of that.
I found a strange work around for this if you have some private types you can’t normally access that you need to provoke AOT code generation: You can hack the compiler to not bother with visibility. It’s kind of dirty, but since the code never runs at compile time I don’t feel quite as bad about it.
I would like to know how to setup my link.xml file so that admob doesn’t crash. I want to preserve everything admob needs in the link.xml file. Anyone know what I should preserve or how to find out?