Skip to content
This repository has been archived by the owner on Nov 12, 2020. It is now read-only.

Build issue in Release mode (Linking SDK Assemblies) #92

Open
hemantramu opened this issue Apr 11, 2019 · 19 comments
Open

Build issue in Release mode (Linking SDK Assemblies) #92

hemantramu opened this issue Apr 11, 2019 · 19 comments

Comments

@hemantramu
Copy link

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()

@ChaseFlorell
Copy link
Contributor

Before I start digging into this, did you ensure you did a full clean/delete bin/rebuild?
Sometimes Visual Studio gets confused.

@hemantramu
Copy link
Author

Yes i have done full clean/delete bin/rebuild and even nuget downgraded / upgraded the package as well

@hemantramu
Copy link
Author

Any update on the above issue

@AbdulazizDbekhi
Copy link

I have this issue too, I tried everything to solve it, nothing helped me. Please @ChaseFlorell, try to fix it. Thanks.

@hemantramu
Copy link
Author

Still facing the same issue in different solutions as well

@MDemetrio
Copy link

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. 😄

@eamiguinho
Copy link

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.

@LaBoss
Copy link

LaBoss commented Jun 17, 2019

+1 with the same problem when upgrading to Xamarin 4 starts giving Linker errors

@rodrigueslg
Copy link

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

@NiketanMhatre
Copy link

+1 with same problem in debug mode too with XF 4.1. Visual Studio 2019 16.2.0 and latest XFx control.

@mahmoudAbdin
Copy link

Me too facing the same problem .. any updates ?

@MRomeror
Copy link

I have the same problem... Any solution?

@DeShrike
Copy link

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.

@DeShrike DeShrike mentioned this issue Nov 21, 2019
3 tasks
@rubberydev
Copy link

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.

@pablortpo
Copy link

I have this error, any solution?

@fchihe
Copy link

fchihe commented Jan 29, 2020

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 :

  1. Download Xfx.Controls sources. Update Xamarin.Forms references from version 3.5.0.129452 to version 3.6.0.709228
  2. Compile Xfx.Controls , Xfx.Controls.Droid, Xfx.Controls.iOS to get dlls
  3. In your main project, instead of referencing Xfx Nuget package, reference the dlls you just compiled.
  4. Try to run your main project with "linking SDK Assemblies", it should work.

@pablortpo
Copy link

Thanks @fchihe , i will try to do.

@pavanalluri007
Copy link

Thanks @fchihe this worked for us.

@AlisuTech
Copy link

AlisuTech commented Sep 17, 2020

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!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests