- Home /
Can't seem to get link.xml working with AWS SDK
Hi, having a horribly difficult time here, been trying to fix this for hours...
We're using the AWS SDK and it seems to be getting stripped, specifically a constructor inside one of the assemblies. This is the error we're encountering in Xcode when the games runs on a device:
MissingMethodException: Method not found: 'Default constructor not found...ctor() of Amazon.Util.Internal.PlatformServices.NetworkReachability'.
I've tried setting up the link.xml file in both of the following ways:
<linker>
<assembly fullname="AWSSDK.Core" preserve="all"/>
<assembly fullname="AWSSDK.CognitoIdentity" preserve="all"/>
<assembly fullname="AWSSDK.SecurityToken" preserve="all"/>
<assembly fullname="AWSSDK.DynamoDBv2" preserve="all"/>
<assembly fullname="UnityEngine">
<type fullname="UnityEngine.Experimental.Networking.UnityWebRequest" preserve="all" />
<type fullname="UnityEngine.Experimental.Networking.UploadHandlerRaw" preserve="all" />
<type fullname="UnityEngine.Experimental.Networking.UploadHandler" preserve="all" />
<type fullname="UnityEngine.Experimental.Networking.DownloadHandler" preserve="all" />
<type fullname="UnityEngine.Experimental.Networking.DownloadHandlerBuffer" preserve="all" />
</assembly>
<assembly fullname="mscorlib">
<namespace fullname="System.Security.Cryptography" preserve="all"/>
</assembly>
<assembly fullname="System">
<namespace fullname="System.Security.Cryptography" preserve="all"/>
</assembly>
</linker>
...and this way...
<linker>
<assembly fullname="AWSSDK.Core">
<namespace fullname="Amazon.Util.Internal.PlatformServices" preserve="all"/>
</assembly>
<assembly fullname="AWSSDK.CognitoIdentity">
<namespace fullname="Amazon.Util.Internal.PlatformServices" preserve="all"/>
</assembly>
<assembly fullname="AWSSDK.SecurityToken">
<namespace fullname="Amazon.Util.Internal.PlatformServices" preserve="all"/>
</assembly>
<assembly fullname="AWSSDK.DynamoDBv2">
<namespace fullname="Amazon.Util.Internal.PlatformServices" preserve="all"/>
</assembly>
<assembly fullname="UnityEngine">
<type fullname="UnityEngine.Experimental.Networking.UnityWebRequest" preserve="all" />
<type fullname="UnityEngine.Experimental.Networking.UploadHandlerRaw" preserve="all" />
<type fullname="UnityEngine.Experimental.Networking.UploadHandler" preserve="all" />
<type fullname="UnityEngine.Experimental.Networking.DownloadHandler" preserve="all" />
<type fullname="UnityEngine.Experimental.Networking.DownloadHandlerBuffer" preserve="all" />
</assembly>
<assembly fullname="mscorlib">
<namespace fullname="System.Security.Cryptography" preserve="all"/>
</assembly>
<assembly fullname="System">
<namespace fullname="System.Security.Cryptography" preserve="all"/>
</assembly>
</linker>
Neither of them seem to be working. Using the Assembly Browser in Mono and switching between C# and IL, I can see IL is missing the constructor that is clearly present in C#.
Any help would be greatly appreciated, running out of things to try. Thanks!
Answer by Durston88 · Jun 21, 2016 at 09:25 PM
So I did actually figure this out. Eventually I got it working by using the second method and also manually setting the import settings on the libraries from "Any Platform" to "iOS, Android, Editor".
This let it run and connect to DynamoDB, but then it was unable to parse the data (or something), giving the error "Type System.String is unsupported, it cannot be instantiated". This was fixed by reverting the Dynamo assembly line back to the original format. Anyway, if none of that makes sense, this is what it ended up looking like:
<linker>
<assembly fullname="UnityEngine">
<type fullname="UnityEngine.Experimental.Networking.UnityWebRequest" preserve="all" />
<type fullname="UnityEngine.Experimental.Networking.UploadHandlerRaw" preserve="all" />
<type fullname="UnityEngine.Experimental.Networking.UploadHandler" preserve="all" />
<type fullname="UnityEngine.Experimental.Networking.DownloadHandler" preserve="all" />
<type fullname="UnityEngine.Experimental.Networking.DownloadHandlerBuffer" preserve="all" />
</assembly>
<assembly fullname="mscorlib">
<namespace fullname="System.Security.Cryptography" preserve="all"/>
</assembly>
<assembly fullname="System">
<namespace fullname="System.Security.Cryptography" preserve="all"/>
</assembly>
<assembly fullname="AWSSDK.Core">
<type fullname="Amazon.Util.Internal.PlatformServices.NetworkReachability" preserve="all"/>
<namespace fullname="Amazon.Util.Internal.PlatformServices" preserve="all"/>
</assembly>
<assembly fullname="AWSSDK.CognitoIdentity">
<namespace fullname="Amazon.Util.Internal.PlatformServices" preserve="all"/>
</assembly>
<assembly fullname="AWSSDK.SecurityToken">
<namespace fullname="Amazon.Util.Internal.PlatformServices" preserve="all"/>
</assembly>
<assembly fullname="AWSSDK.DynamoDBv2" preserve="all"/>
</linker>
Bah, it is escaping the code snippets sorry. Using '[]' ins$$anonymous$$d of '<>'. Hey JumpDog, I am having the same "Type System.String is unsupported, it cannot be instantiated" issue, but reverting that back to the suggested format:
[assembly fullname="AWSSD$$anonymous$$.DynamoDBv2" preserve="all" /]
didn't work for me. I also tried:
[assembly fullname="AWSSD$$anonymous$$.DynamoDBv2"] [namespace fullname="Amazon.DynamoDBv2.Data$$anonymous$$odel" preserve="all" /] [/assembly]And
[assembly fullname="AWSSD$$anonymous$$.DynamoDBv2"/]
And
[assembly fullname="AWSSD$$anonymous$$.DynamoDBv2"] [namespace fullname="Amazon.Util.Internal.PlatformServices" preserve="all" /] [/assembly]No luck though. Any additional things you can think to try? Thanks!
Not sure, what I wrote above is what worked for me. I actually tried changing the import setting on those files back to "Any Platform" just now to see if that played a part, to make sure you did that too if so... but doesn't seem like that was part of it after all. If anything comes to $$anonymous$$d I'll post again but you tried what did it for me. Good luck.
@JumpDog no worries thanks for trying. I ended up changing each one to:
[assembly fullname="AWSSD$$anonymous$$.CognitoIdentity"] [type fullname="Amazon.*" preserve="all" /] [namespace fullname="Amazon.Util.Internal.PlatformServices" preserve="all" /] [/assembly]And that worked for me. Hopefully that helps someone else making the transition.
Thanks guys! This was tremendously helpful. For those wondering WHY this fix is needed:
https://docs.unity3d.com/$$anonymous$$anual/iphone-playerSizeOptimization.html preserve="all" on an assembly only works in IL2CPP builds.
I guess amazon mostly did QA on iPhone, not on anrdoid using the $$anonymous$$ono2X scripting backend...
Answer by scottstephan · Dec 11, 2016 at 04:59 PM
This is a silly question, but where is link.xml meant to be? In /Assets ? Is that the assembly root?
Answer by RedHatJef · Jul 04, 2019 at 09:55 PM
I ran into this to trying to get GameLift to work. No combination of anything I tried could make this work. The solution was to refer to the example unity project amazon provides with their AWSSDK.
Basically, just include this in the base Assets folder:
https://github.com/aws/aws-sdk-net/blob/master/sdk/test/Unity/Unity3DTests/Assets/link.xml
Once I did this, and rebuilt projects, it just magically worked.
Answer by Gwom · Oct 20, 2020 at 04:57 PM
Had a slightly different link.xml, moved it to the root of the asset folder, really not sure if it was this or changing from IL2CPP to Mono but finally got it working.
<linker>
<assembly fullname="UnityEngine">
<type fullname="UnityEngine.Experimental.Networking.UnityWebRequest" preserve="all" />
<type fullname="UnityEngine.Experimental.Networking.UploadHandlerRaw" preserve="all" />
<type fullname="UnityEngine.Experimental.Networking.UploadHandler" preserve="all" />
<type fullname="UnityEngine.Experimental.Networking.DownloadHandler" preserve="all" />
<type fullname="UnityEngine.Experimental.Networking.DownloadHandlerBuffer" preserve="all" />
</assembly>
<assembly fullname="mscorlib">
<namespace fullname="System.Security.Cryptography" preserve="all"/>
</assembly>
<assembly fullname="System">
<namespace fullname="System.Security.Cryptography" preserve="all"/>
</assembly>
<assembly fullname="AWSSDK.Core" preserve="all"/>
<assembly fullname="AWSSDK.CognitoIdentity" preserve="all"/>
<assembly fullname="AWSSDK.SecurityToken" preserve="all"/>
<assembly fullname="log4net" preserve="all"/>
<assembly fullname="System.Configuration" preserve="all"/>
<assembly fullname="AWSSDK.Core">
<type fullname="Amazon.Util.Internal.PlatformServices.NetworkReachability" preserve="all"/>
<namespace fullname="Amazon.Util.Internal.PlatformServices" preserve="all"/>
</assembly>
<assembly fullname="AWSSDK.CognitoIdentity">
<namespace fullname="Amazon.Util.Internal.PlatformServices" preserve="all"/>
</assembly>
<assembly fullname="AWSSDK.SecurityToken">
<namespace fullname="Amazon.Util.Internal.PlatformServices" preserve="all"/>
</assembly>
<assembly fullname="AWSSDK.DynamoDBv2" preserve="all"/>
</linker>
Your answer
Follow this Question
Related Questions
Best way to preserve a class from Code Stripping 0 Answers
link.xml for a monobehaviour? 1 Answer
Using HttpWebRequest when Stripping Assemblies 1 Answer
Place a link in another browser window. 3 Answers
Health Tutorial broken link to script 4 Answers