Kevin Baretto
Kevin Baretto

Reputation: 21

The "LinkAssemblies" task failed unexpectedly while publishing apk file

I am using Xamarin Forms to develop a mobile app.I am able to deploy the app in debug mode and the app builds with no errors.I am trying to publish apk in release mode but getting below error.I have used Syncfusion SFchart and SFGauge.Kindly help and find below error description:

C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(5,5): Error MSB4018: The "LinkAssemblies" task failed unexpectedly.
Xamarin.Android.XamarinAndroidException: error XA2006: Reference to metadata item 'System.Int32 Xamarin.Forms.Platform.Android.Resource/Attribute::actionBarSize' (defined in 'Syncfusion.SfGauge.XForms.Android, Version=14.2451.0.26, Culture=neutral, PublicKeyToken=null') from 'Syncfusion.SfGauge.XForms.Android, Version=14.2451.0.26, Culture=neutral, PublicKeyToken=null' could not be resolved. ---> Mono.Cecil.ResolutionException: Failed to resolve System.Int32 Xamarin.Forms.Platform.Android.Resource/Attribute::actionBarSize
at Mono.Linker.Steps.MarkStep.MarkField(FieldReference reference)
at Mono.Linker.Steps.MarkStep.MarkInstruction(Instruction instruction)
at Mono.Linker.Steps.MarkStep.MarkMethodBody(MethodBody body)
at Mono.Linker.Steps.MarkStep.ProcessMethod(MethodDefinition method)
at Mono.Linker.Steps.MarkStep.ProcessQueue()
at Mono.Linker.Steps.MarkStep.Process()
at Mono.Linker.Steps.MarkStep.Process(LinkContext context)
at Mono.Linker.Pipeline.Process(LinkContext context)
at MonoDroid.Tuner.Linker.Process(LinkerOptions options, LinkContext& context)
at Xamarin.Android.Tasks.LinkAssemblies.Execute()
--- End of inner exception stack trace ---
at Xamarin.Android.Diagnostic.Error(Int32 code, Exception innerException, String message, Object[] args)
at Xamarin.Android.Tasks.LinkAssemblies.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.d__26.MoveNext() (MSB4018) (EWSMobile.Droid)

Upvotes: 1

Views: 699

Answers (2)

Subburaj Pandian
Subburaj Pandian

Reputation: 106

Issue resolved with latest Xamarin.Forms Nuget packages (v 2.3.0.107), the mentioned issue occurs with older version of Xamarin.Forms packages.

Subburaj Pandian V.

Upvotes: 2

Jon Douglas
Jon Douglas

Reputation: 13176

Your main issue is the following:

error XA2006: Reference to metadata item 'System.Int32 Xamarin.Forms.Platform.Android.Resource/Attribute::actionBarSize' (defined in 'Syncfusion.SfGauge.XForms.Android, Version=14.2451.0.26, Culture=neutral, PublicKeyToken=null') from 'Syncfusion.SfGauge.XForms.Android, Version=14.2451.0.26, Culture=neutral, PublicKeyToken=null' could not be resolved. ---> Mono.Cecil.ResolutionException: Failed to resolve System.Int32 Xamarin.Forms.Platform.Android.Resource/Attribute::actionBarSize

This means that the Attribute actionBarSize cannot be found or is not included in your Resource.designer.cs file. There are a few typical issues of why this happens:

1) You are not compiling against the latest Android API (API 23 at the current time of writing)

2) The referenced library might be out of date and should be updated and compiled against the latest Android API. (API 23 currently)

3) If you are using Xamarin.Forms, you should ensure you use the version that was compiled with the third party library.

https://developer.android.com/reference/android/R.attr.html#actionBarSize

As additional debugging steps:

1) Set your Linker setting in Release configuration to Don't Link/None.

https://developer.xamarin.com/guides/android/advanced_topics/linking/#Linker_Behavior

If it works here, you know that a type is being linked out of this library.

2) Preserve the linked out type

You can use linkskip to linkskip the assembly:

https://developer.xamarin.com/guides/android/advanced_topics/linking/#linkskip

Otherwise you can readup on general Linking here:

https://developer.xamarin.com/guides/android/advanced_topics/linking

Upvotes: 2

Related Questions