2
Next, I am finishing my project and as last step I am trying to "archive" my android project, however while trying to archive it generates the following error:
Erro Falha inesperada da tarefa "LinkAssemblies".
Mono.Linker.MarkException: Error processing method: 'System.Void Xamarin.Forms.Pages.BaseDataSource/<Initialize>d__22::MoveNext()' in assembly: 'Xamarin.Forms.Pages.dll' ---> Mono.Cecil.ResolutionException: Failed to resolve System.Void Xamarin.Forms.Log::Warning(System.String,System.String)
em Mono.Linker.Steps.MarkStep.HandleUnresolvedMethod(MethodReference reference)
em Mono.Linker.Steps.MarkStep.MarkMethod(MethodReference reference)
em Mono.Linker.Steps.MarkStep.MarkInstruction(Instruction instruction)
em Mono.Linker.Steps.MarkStep.MarkMethodBody(MethodBody body)
em Mono.Linker.Steps.MarkStep.ProcessMethod(MethodDefinition method)
em Mono.Linker.Steps.MarkStep.ProcessQueue()
--- Fim do rastreamento de pilha de exceções internas ---
em Mono.Linker.Steps.MarkStep.ProcessQueue()
em Mono.Linker.Steps.MarkStep.ProcessEntireQueue()
em Mono.Linker.Steps.MarkStep.Process()
em Mono.Linker.Steps.MarkStep.Process(LinkContext context)
em Mono.Linker.Pipeline.Process(LinkContext context)
em MonoDroid.Tuner.Linker.Process(LinkerOptions options, ILogger logger, LinkContext& context)
em Xamarin.Android.Tasks.LinkAssemblies.Execute(DirectoryAssemblyResolver res)
em Xamarin.Android.Tasks.LinkAssemblies.Execute()
em Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
em Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext() AppRDVAUX.Android C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets 1748
After a lot of searching I noticed that this error is related to an option marked in Android.Manifest called Linker(linking), in Voce you have the option to "compress" your application so that it doesn’t get too big. Without this option checked my project generates apk, however it gets very large(70mb). So to sum up, does anyone know how to make this binding option work or has any other way to make the generated apk get smaller? Thanks in advance to those who can answer.
Hello Diego, thank you for answering, I removed some libraries from my project that I believe were responsible for not archiving my project (in my case they were Xamarin.Theme.Base, Xamarin.Theme.Ligth, Xamarin.Theme.Dark ), I adjusted the project and selected the option to link "SDK Assemblies Only" it managed to archive, generated the apk and to my surprise the size was not reduced at all, still a file of giant size for an apk. Anyway, this already problem for another topic and I am researching more on the subject. I thank you again for your help.
– Q.Wesley
@Q.Wesley if Linker hasn’t made a difference in apk size, we have two options: either some library you’re using is too large or virtually all of the app’s content is being preserved and Linker is having no effect. A project hello world simple would already have a reduction of 70 to 87% apk size. Check Bitdiffer
– Diego Rafael Souza
Hi Diego, thanks for the help, I managed to generate an apk with 15mb (it was already a tremendous difference), I got this by redoing the whole project, started a new project updated everything, all libraries, files, imported the classes of my project enabled the options and worked, I don’t know exactly what was wrong, but it worked. I will not stop looking at the Bitdiffer you indicated, is a tool that will definitely help me a lot. Thanks again.
– Q.Wesley
Ball show. 15 Mb already makes things easier. =)
– Diego Rafael Souza