3

When running my app in Release mode in Xamarin I get the following error with 'Link SDK assemblies only' on:

/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets: Error: Error executing task LinkAssemblies: error XA2006: Reference to metadata item 'System.IO.Ports.SerialPort' (defined in 'EftPay, Version=1.2.0.0, Culture=neutral, PublicKeyToken=e6147cbb02cecb0d') from 'EftPay, Version=1.2.0.0, Culture=neutral, PublicKeyToken=e6147cbb02cecb0d' could not be resolved. (mPOS)

I am using a third-party library that uses the SerialPort reference in a class (as seen in the error), however, I do not use that specific class. Is there a way I can tell the linker to not strip this reference?

Thanks for any help.

Federico Navarrete
  • 3,069
  • 5
  • 41
  • 76
Byron
  • 1,313
  • 10
  • 22
  • Did you try using PreserveAttribute with your class? Here is a reference, just in case: http://developer.xamarin.com/guides/android/advanced_topics/linking/ – Meringros Mar 18 '15 at 15:16
  • Yes I have tried this without success. – Byron Mar 19 '15 at 13:58

1 Answers1

3

Did you tried to create a static class that "uses" SerialPort class? Something similar to this: https://github.com/MvvmCross/MvvmCross/blob/v3/nuspec/DroidContent/LinkerPleaseInclude.cs.pp

Or you could try to LinkSkip that assembly

<PropertyGroup>
     <AndroidLinkSkip>Assembly1;Assembly2</AndroidLinkSkip>
</PropertyGroup>
Adam Ivancza
  • 2,459
  • 1
  • 25
  • 36
  • Yes I have attempted this however the System.IO.Port class is not even available in monoandroid so I cannot even declare it. I have also tried the linkskip property and preserve attributes with no success. – Byron Mar 19 '15 at 14:12
  • O_o. It seems like that's the case - System.IO.Port is not part of the Monodroid. Check out these links: http://stackoverflow.com/questions/5653890/monodroid-lacks-support-for-system-io-ports https://bugzilla.novell.com/show_bug.cgi?id=687407 My last idea is that you should try to LinkSkip the third party library. If that not helps then you should stick with the "Skip Linking" instead of "Link SDK Assemblies" setting. – Adam Ivancza Mar 19 '15 at 15:21
  • Yeah thanks I have seen most of these posts. I guess I am stuck with no linking. It just creates a massive .apk that is not ideal. – Byron Mar 19 '15 at 15:41