Build issue in Release mode (Linking SDK Assemblies)
hemantramu opened this issue ยท 19 comments
We are using the XfxControls package in a Xamarin.Forms app (Droid and iOS). The Xamarin Forms version is 3.6.0.293080. When we try to compile our primary Droid platform project, we get a build error that the "LinkAssemblies task failed unexpectedly." The actual build error is quoted below. When we build the project in "Debug" mode, it works fine. If we select "Don't Link" in the Linker Behavior section of the Droid project options in the Release configuration, the build completes.
Version Number of Control: 1.1.3 / 1.2.1
Device Tested On: Debug Working
Simulator Tested On: N/A
Affects
iOS - Not Tested Yet
Android (Min version API19, target version API28, Xamarin Android version 9, SDK Tools version 26.1.1, SDK Platform Tools version 28.0.1, SDK Build Tools version 27.0.3)
Expected Behavior
Project compiles without any linker errors
Actual Behavior
Droid project compilation fails with linker exception like this:
\2017\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2129,5): error MSB4018: The "LinkAssemblies" task failed unexpectedly.
\2017\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2129,5): error MSB4018: Mono.Linker.MarkException: Error processing method: 'System.Void Xfx.Controls.Droid.Renderers.XfxCardViewRendererDroid::Xamarin.Forms.Platform.Android.IVisualElementRenderer.add_LayoutChange(System.EventHandler1<Android.Views.View/LayoutChangeEventArgs>)' in assembly: 'Xfx.Controls.Droid.dll' ---> Mono.Cecil.ResolutionException: Failed to resolve System.Void Xamarin.Forms.Platform.Android.IVisualElementRenderer::add_LayoutChange(System.EventHandler1<Android.Views.View/LayoutChangeEventArgs>)
\2017\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2129,5): error MSB4018: at Mono.Linker.Steps.MarkStep.HandleUnresolvedMethod(MethodReference reference)
\2017\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2129,5): error MSB4018: at Mono.Linker.Steps.MarkStep.MarkMethod(MethodReference reference)
\2017\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2129,5): error MSB4018: at Mono.Linker.Steps.MarkStep.ProcessMethod(MethodDefinition method)
\2017\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2129,5): error MSB4018: at Mono.Linker.Steps.MarkStep.ProcessQueue()
\2017\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2129,5): error MSB4018: --- End of inner exception stack trace ---
\2017\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2129,5): error MSB4018: at Mono.Linker.Steps.MarkStep.ProcessQueue()
\2017\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2129,5): error MSB4018: at Mono.Linker.Steps.MarkStep.ProcessPrimaryQueue()
\2017\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2129,5): error MSB4018: at Mono.Linker.Steps.MarkStep.Process()
\2017\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2129,5): error MSB4018: at MonoDroid.Tuner.MonoDroidMarkStep.Process(LinkContext context)
\2017\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2129,5): error MSB4018: at Mono.Linker.Pipeline.Process(LinkContext context)
\2017\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2129,5): error MSB4018: at MonoDroid.Tuner.Linker.Process(LinkerOptions options, ILogger logger, LinkContext& context)
\2017\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2129,5): error MSB4018: at Xamarin.Android.Tasks.LinkAssemblies.Execute(DirectoryAssemblyResolver res)
\2017\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2129,5): error MSB4018: at Xamarin.Android.Tasks.LinkAssemblies.Execute()
\2017\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2129,5): error MSB4018: at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
\2017\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2129,5): error MSB4018: at Microsoft.Build.BackEnd.TaskBuilder.d__26.MoveNext()
Before I start digging into this, did you ensure you did a full clean/delete bin/rebuild?
Sometimes Visual Studio gets confused.
Yes i have done full clean/delete bin/rebuild and even nuget downgraded / upgraded the package as well
Any update on the above issue
I have this issue too, I tried everything to solve it, nothing helped me. Please @ChaseFlorell, try to fix it. Thanks.
Still facing the same issue in different solutions as well
I'm also facing this issue.
I did some research on this and looks like it's related with this PR, specifically this change
which removes the LayoutChange EventHandler from IVisualElementRenderer.
I did some tests that show the following:
VS Community 2019 16.0.3;
Xamarin Android: 9.2.3.0;
SDK Tools: 26.1.1;
SDK Platform Tools: 28.0.1;
Xfx.Controls: 1.2.1;
Linking: SdkAssemblies;
Release;
Tests on a newly created Blank App and the Xfx.Controls.Example(from this source, referencing library directly) changing only XF version:
Blank App
- 3.5.0.129452 - Success
- 3.5.0.169047 - Success
- 3.5.0.274416 - Failing
- 3.6.0.220655 -Failing
- 3.6.0.344457 -Failing
- 4.0.0-pre9 - Failing
Example App
- 3.5.0.129452 - Success
- 3.5.0.169047 - Success
- 3.5.0.274416 -Failing
- 3.6.0.220655 -Failing
- 3.6.0.344457 -Failing
So, the PR is said to be merged on XF 3.6.0 but it starts to fail if we reference XF 3.5.0.274416 which in fact does not contain the LayoutChange EventHandler on the interface.
Then I tried updating the Xfx.Controls XF reference to versions >= 3.5.0.274416 and it succeeded on these scenarios:
- Xfx.Controls.Example.(Standard, iOS, Droid): XF 3.5.0.274416 &
Xfx.Controls.(Standard, iOS, Droid): 3.5.0.274416 - Xfx.Controls.Example.(Standard, iOS, Droid): XF 3.6.0.344457 &
Xfx.Controls.(Standard, iOS, Droid): 3.5.0.274416 - Xfx.Controls.Example.(Standard, iOS, Droid): XF 3.6.0.344457 &
Xfx.Controls.(Standard, iOS, Droid): 3.6.0.344457
While Xfx is not updated to a newer XF version, I went in search of a workaround for my project, tried configuring custom linking, overwriting XfxCardViewRenderer and using falseflag but nothing worked.
I also tried some fixes on Xfx code without updating XF version but didn't come out with nothing...
I hope my info helps on this. ๐
Having the same issue here, the only way to make it work is not to linked assemblies on the android project settings, but of course, these will raise the APK size quite a fair amount.
+1 with the same problem when upgrading to Xamarin 4 starts giving Linker errors
MDemetrio did a great job detailing the bug, so please fix it quickly
I have the same problem when running on Xamarin.Forms.3.6.0.344457
In debug mode there's no error, but in release mode there are linking erros
+1 with same problem in debug mode too with XF 4.1. Visual Studio 2019 16.2.0 and latest XFx control.
Me too facing the same problem .. any updates ?
I have the same problem... Any solution?
I have the same issue.
I have created a PR to update packages.
In my initial tests this issue seems to be fixed with these updates.
This issue is related to #44 , Please @ChaseFlorell is it possible, provide us a solution.
The only way to make it work is not to linked assemblies on the android project settings, but of course, these will raise the APK size quite a fair amount. as @eamiguinho said.
Thanks in advance.
I have this error, any solution?
Yes there is a solution.
The solution provided @DeShrike is working... but because the owner (@ChaseFlorell ) hasn't accept @DeShrike pull request yet, you will have to do it by yourself (and in my opinion it's a very ugly way to fix the problem)
What I did :
- Download Xfx.Controls sources. Update Xamarin.Forms references from version 3.5.0.129452 to version 3.6.0.709228
- Compile Xfx.Controls , Xfx.Controls.Droid, Xfx.Controls.iOS to get dlls
- In your main project, instead of referencing Xfx Nuget package, reference the dlls you just compiled.
- Try to run your main project with "linking SDK Assemblies", it should work.
Thanks @fchihe this worked for us.
We were able to fix this issue following this process;
-
Clone XFXControl repository
-
Update the Android Support Nuggets to 28.0.0.3
-
Update Xamarin Forms Nugget Package to 3.6+
-
Rebuild the Xamarin Forms Shared Project, Android and iOS projects
-
Copy the dlls for the three projects xfxcontrol, xfxcontrol.droid, xfxcontrol.ios
-
Uninstall the xfxxontrol Nuget Package and add the dlls as references in the shared Xamarin forms project
-
Clean the project and Rebuild in Release mode... It should build fine now!