Forum Xamarin.Forms

Error during release build

AgredoAgredo USMember ✭✭

Unerwarteter Fehler bei der LinkAssemblies-Aufgabe.
Mono.Linker.MarkException: Error processing method: 'Android.Views.ScaleGestureDetector Xamarin.Forms.Platform.Android.GestureManager::InitializeScaleDetector()' in assembly: 'Xamarin.Forms.Platform.Android.dll' ---> Mono.Cecil.ResolutionException: Failed to resolve System.Void Android.Support.V4.View.ScaleGestureDetectorCompat::SetQuickScaleEnabled(Android.Views.ScaleGestureDetector,System.Boolean)
bei Mono.Linker.Steps.MarkStep.HandleUnresolvedMethod(MethodReference reference)
bei Mono.Linker.Steps.MarkStep.MarkMethod(MethodReference reference)
bei Mono.Linker.Steps.MarkStep.MarkInstruction(Instruction instruction)
bei Mono.Linker.Steps.MarkStep.MarkMethodBody(MethodBody body)
bei Mono.Linker.Steps.MarkStep.ProcessMethod(MethodDefinition method)
bei Mono.Linker.Steps.MarkStep.ProcessQueue()
--- Ende der internen Ausnahmestapelüberwachung ---
bei Mono.Linker.Steps.MarkStep.ProcessQueue()
bei Mono.Linker.Steps.MarkStep.ProcessPrimaryQueue()
bei Mono.Linker.Steps.MarkStep.Process()
bei MonoDroid.Tuner.MonoDroidMarkStep.Process(LinkContext context)
bei Mono.Linker.Pipeline.Process(LinkContext context)
bei MonoDroid.Tuner.Linker.Process(LinkerOptions options, ILogger logger, LinkContext& context)
bei Xamarin.Android.Tasks.LinkAssemblies.Execute(DirectoryAssemblyResolver res)
bei Xamarin.Android.Tasks.LinkAssemblies.Execute()
bei Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
bei Microsoft.Build.BackEnd.TaskBuilder.d__26.MoveNext() Retailer.Android

Hello,
my code shows this error trying to build a release version.

Can someone explain me what
s happend?

Answers

  • jezhjezh Member, Xamarin Team Xamurai

    You can try to enable the Linking option to None.
    Just right click the app and select Properties, then you will see the following image.

    Note: We can see from Linking on Android

    The linker employes static analysis of your application to determine which assemblies are actually used, which types are actually used, and which members are actually used.Then everything outside of this closure is discarded.

    The primary mechanism for controlling the linker is the Linker Behavior. There are three options:

    1. Don't Link (None in Visual Studio)

    2. Link SDK Assemblies (Sdk Assemblies Only)

    3. Link All Assemblies (Sdk and User Assemblies)

      The Don't Link option turns off the linker; This is useful for troubleshooting runtime failures, to see if the linker is responsible.

      The **Link SDK Assemblies **option only links assemblies that come with Xamarin.Android. All other assemblies (such as your code) are not linked.

      The Link All Assemblies option links all assemblies, which means your code may also be removed if there are no static references.

    So , the linker will sometimes remove code that you want to preserve(such as System.Reflection.MemberInfo.Invoke). And that lead to this situation you are in.
    For more information, please refer to Jonathan Peppers’s articles , chapter : The Linker and Java Binding Projects.
    Link: http://jonathanpeppers.com/Blog/xamarin-forms-performance-on-android

  • AgredoAgredo USMember ✭✭

    Thank you but this is already set. I no App can I build for release. (iOS UWP Android)

  • RubberyDevRubberyDev Member ✭✭

    Hi everyone.

    I have the same issue, but is related to XfxControls nuget:

    error XALNK7000: 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>)
    C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2056,5): error XALNK7000: at Mono.Linker.Steps.MarkStep.HandleUnresolvedMethod(MethodReference reference)
    C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2056,5): error XALNK7000: at Mono.Linker.Steps.MarkStep.MarkMethod(MethodReference reference)
    C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2056,5): error XALNK7000: at Mono.Linker.Steps.MarkStep.ProcessMethod(MethodDefinition method)
    C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2056,5): error XALNK7000: at Mono.Linker.Steps.MarkStep.ProcessQueue()
    C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2056,5): error XALNK7000: --- End of inner exception stack trace ---
    C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2056,5): error XALNK7000: at Mono.Linker.Steps.MarkStep.ProcessQueue()
    C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2056,5): error XALNK7000: at Mono.Linker.Steps.MarkStep.ProcessPrimaryQueue()
    C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2056,5): error XALNK7000: at Mono.Linker.Steps.MarkStep.Process()
    C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2056,5): error XALNK7000: at Mono.Linker.Steps.MarkStep.Process(LinkContext context)
    C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2056,5): error XALNK7000: at MonoDroid.Tuner.MonoDroidMarkStep.Process(LinkContext context)
    C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2056,5): error XALNK7000: at Mono.Linker.Pipeline.ProcessStep(LinkContext context, IStep step)
    C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2056,5): error XALNK7000: at Mono.Linker.Pipeline.Process(LinkContext context)
    C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2056,5): error XALNK7000: at MonoDroid.Tuner.Linker.Process(LinkerOptions options, ILogger logger, LinkContext& context)
    C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2056,5): error XALNK7000: at Xamarin.Android.Tasks.LinkAssemblies.Execute(DirectoryAssemblyResolver res)
    C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2056,5): error XALNK7000: at Xamarin.Android.Tasks.LinkAssemblies.RunTask()
    C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2056,5): error XALNK7000: at Xamarin.Android.Tasks.AndroidTask.Execute()

    Please, someone could you help me with any different idea to solve problem, when I set link = None the .apk is signed successfull, however the size is 75mb.

    Thanks in advance.

  • pablortpopablortpo Member ✭✭

    Everybody know any solution, i has this error

    Error 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>)
    en Mono.Linker.Steps.MarkStep.HandleUnresolvedMethod(MethodReference reference)
    en Mono.Linker.Steps.MarkStep.MarkMethod(MethodReference reference)
    en Mono.Linker.Steps.MarkStep.ProcessMethod(MethodDefinition method)
    en Mono.Linker.Steps.MarkStep.ProcessQueue()
    --- Fin del seguimiento de la pila de la excepción interna ---
    en Mono.Linker.Steps.MarkStep.ProcessQueue()
    en Mono.Linker.Steps.MarkStep.ProcessPrimaryQueue()
    en Mono.Linker.Steps.MarkStep.Process()
    en Mono.Linker.Steps.MarkStep.Process(LinkContext context)
    en MonoDroid.Tuner.MonoDroidMarkStep.Process(LinkContext context)
    en Mono.Linker.Pipeline.ProcessStep(LinkContext context, IStep step)
    en Mono.Linker.Pipeline.Process(LinkContext context)
    en MonoDroid.Tuner.Linker.Process(LinkerOptions options, ILogger logger, LinkContext& context)
    en Xamarin.Android.Tasks.LinkAssemblies.Execute(DirectoryAssemblyResolver res)
    en Xamarin.Android.Tasks.LinkAssemblies.RunTask()
    en Xamarin.Android.Tasks.AndroidTask.Execute()

  • TymurTkachenkoTymurTkachenko USMember

    I know this is an old question, but my answer might help somebody. I had the similar issue, and I found the solution: delete cached object files. Clean All command doesn't help in this case, you should manually delete all obj and bin directories in solution directory.

  • GaelmartGaelmart Member ✭✭

    Me too.

    Internet is covered with this error with no solutions.

    Severity Code Description Project File Line Suppression State
    Error Mono.Linker.MarkException: Error processing method: 'System.Void AndroidX.RecyclerView.Widget.RecyclerView/LayoutManager::n_OnInitializeAccessibilityNodeInfo_Landroidx_recyclerview_widget_RecyclerView_Recycler_Landroidx_recyclerview_widget_RecyclerView_State_Landroidx_core_view_accessibility_AccessibilityNodeInfoCompat_(System.IntPtr,System.IntPtr,System.IntPtr,System.IntPtr,System.IntPtr)' in assembly: 'Xamarin.AndroidX.RecyclerView.dll' ---> Mono.Cecil.ResolutionException: Failed to resolve AndroidX.Core.View.Accessibiity.AccessibilityNodeInfoCompat
    at Mono.Linker.Steps.MarkStep.HandleUnresolvedType(TypeReference reference)
    at Mono.Linker.Steps.MarkStep.MarkType(TypeReference reference)
    at MonoDroid.Tuner.MonoDroidMarkStep.MarkType(TypeReference reference)
    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() iBasisAppV1.Android

Sign In or Register to comment.