question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[bug] android release build fails with linker error

See original GitHub issue

hello,

when attempting a release build on Android i get the following linker error, even though i’m not using MaterialCard, and do invoke XamarinBackgroundKit.Android.BackgroundKit.Init();

iOS builds fine.

2>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2129,5): error MSB4018: The "LinkAssemblies" task failed unexpectedly.
2>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2129,5): error MSB4018: Mono.Linker.MarkException: Error processing method: 'System.Void XamarinBackgroundKit.Android.Renderers.MaterialCardRenderer::.ctor(Android.Content.Context)' in assembly: 'XamarinBackgroundKit.Android.dll' ---> Mono.Cecil.ResolutionException: Failed to resolve Xamarin.Forms.Material.Android.MaterialContextThemeWrapper Xamarin.Forms.Material.Android.MaterialContextThemeWrapper::Create(Android.Content.Context)
2>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2129,5): error MSB4018:    at Mono.Linker.Steps.MarkStep.HandleUnresolvedMethod(MethodReference reference)
2>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2129,5): error MSB4018:    at Mono.Linker.Steps.MarkStep.MarkMethod(MethodReference reference)
2>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2129,5): error MSB4018:    at Mono.Linker.Steps.MarkStep.MarkInstruction(Instruction instruction)
2>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2129,5): error MSB4018:    at Mono.Linker.Steps.MarkStep.MarkMethodBody(MethodBody body)
2>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2129,5): error MSB4018:    at Mono.Linker.Steps.MarkStep.ProcessMethod(MethodDefinition method)
2>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2129,5): error MSB4018:    at Mono.Linker.Steps.MarkStep.ProcessQueue()
2>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2129,5): error MSB4018:    --- End of inner exception stack trace ---
2>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2129,5): error MSB4018:    at Mono.Linker.Steps.MarkStep.ProcessQueue()
2>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2129,5): error MSB4018:    at Mono.Linker.Steps.MarkStep.ProcessPrimaryQueue()
2>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2129,5): error MSB4018:    at Mono.Linker.Steps.MarkStep.Process()
2>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2129,5): error MSB4018:    at MonoDroid.Tuner.MonoDroidMarkStep.Process(LinkContext context)
2>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2129,5): error MSB4018:    at Mono.Linker.Pipeline.Process(LinkContext context)
2>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2129,5): error MSB4018:    at MonoDroid.Tuner.Linker.Process(LinkerOptions options, ILogger logger, LinkContext& context)
2>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2129,5): error MSB4018:    at Xamarin.Android.Tasks.LinkAssemblies.Execute(DirectoryAssemblyResolver res)
2>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2129,5): error MSB4018:    at Xamarin.Android.Tasks.LinkAssemblies.Execute()
2>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2129,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
2>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2129,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:17 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
ChasakisDcommented, Sep 9, 2019

@bentmar I will upload soon a new version without the need of ContextWrapper

1reaction
kicsiedecommented, Jul 30, 2019

honest answer: no time/capacity to fight another shitload of newly introduced bugs in 4.x 😄

4.1 doesn’t build either. but different error ofc. (I don’t think this is related to your component)

2>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2129,5): error MSB4018: The "LinkAssemblies" task failed unexpectedly.
2>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2129,5): error MSB4018: Mono.Linker.MarkException: Error processing method: 'System.Void AndroidBug.App::InitializeComponent()' in assembly: 'AndroidBug.dll' ---> Mono.Cecil.ResolutionException: Failed to resolve System.Void Xamarin.Forms.Internals.ResourceLoader/ResourceLoadingQuery::set_Instance(System.Object)
2>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2129,5): error MSB4018:    at Mono.Linker.Steps.MarkStep.HandleUnresolvedMethod(MethodReference reference)

why do you have Preserve.All though? i’m not even using materialcard, so the the linker could strip it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Xamarin Forms Release version of Android not building ...
This seems to be a similar problem to: Xamarin Android build just hangs when linker is enabled. The solution there was to remove...
Read more >
[Bug] Android Release build fails. Mono.Linker. ...
4>C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1881,5): error ...
Read more >
Known issues with Android Studio and Android Gradle Plugin
This page tracks known issues with Android Studio Giraffe and Android Gradle plugin 8.1.0. If you experience an issue not already included here, ......
Read more >
I'm able to build both Production and Development, but not ...
This error usually means that the executable code in the project is too large. There is a bug in the Android NDK linker...
Read more >
Troubleshoot build errors and crashes
A reference for troubleshooting build errors and crashes when using EAS Build. ... Locally compile and run the Android app in release mode....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found