DaddyProphet
DaddyProphet

Reputation: 124

Getting a linker error when trying to build Android project

I get this linker error every time I attempt to build my Android project, with the linker set to SDK only.

Error       Mono.Linker.MarkException: Error processing method: 'System.ComponentModel.ICustomTypeDescriptor System.Data.Entity.ModelConfiguration.Utilities.AttributeProvider::GetTypeDescriptor(System.Type)' in assembly: 'EntityFramework.dll' ---> Mono.Cecil.ResolutionException: Failed to resolve System.Void System.ComponentModel.DataAnnotations.AssociatedMetadataTypeTypeDescriptionProvider::.ctor(System.Type)
   at Mono.Linker.Steps.MarkStep.HandleUnresolvedMethod(MethodReference reference)
   at Mono.Linker.Steps.MarkStep.MarkMethod(MethodReference 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()
   --- End of inner exception stack trace ---
   at Mono.Linker.Steps.MarkStep.ProcessQueue()
   at Mono.Linker.Steps.MarkStep.ProcessPrimaryQueue()
   at Mono.Linker.Steps.MarkStep.Process()
   at Mono.Linker.Steps.MarkStep.Process(LinkContext context)
   at MonoDroid.Tuner.MonoDroidMarkStep.Process(LinkContext context)
   at Mono.Linker.Pipeline.ProcessStep(LinkContext context, IStep step)
   at Mono.Linker.Pipeline.Process(LinkContext context)
   at MonoDroid.Tuner.Linker.Process(LinkerOptions options, ILogger logger, LinkContext& context)
   at Xamarin.Android.Tasks.LinkAssemblies.Execute(DirectoryAssemblyResolver res)
   at Xamarin.Android.Tasks.LinkAssemblies.RunTask()
   at Xamarin.Android.Tasks.AndroidTask.Execute()   TraceIt.Android         

Build settings: settings settings2 settings3 settings4 settings5 settings6 settings7 settings8

Upvotes: 0

Views: 749

Answers (1)

Dan Gerchcovich
Dan Gerchcovich

Reputation: 525

First make sure to only target Arm64, since this is the default supported architecture now on Google Play.

Second, make sure to switch to a dx compiler instead of d8. I know Google recommends to switch to a d8/r8 compiler implementation but, from experience it's still not stable, and has stripped allot of Apis that previous projects I was involved in dependended on. (Square SDK for example).

Third, it looks like your android client is referencing source code that is not compatable with the Android Runtime. Try to hide the implementation by using SOLID principle of Interface Segregation (where you hide the implementation of the classes through interfaces and dependency injection, and let another library to manage the implementation for you. If you can prevent the client from referencing the implementation that's causing your issue directly, by abstracting it, then the linker should work for you.

Fourth, always make sure to link source code, in order to minimise the size of your apk. Also it speeds up development, and make sure to enable Shared MonoRuntime. It's supported on Android 6 and above.

Upvotes: 1

Related Questions