Linking problems when attempting to deploy

Morning, all. A newbie to Xamarin (and indeed to Android) here, so bear with me if a stupid question.

I'm attempting to deploy my recent app to an Android device, but am getting an error when attempting to do any kind of linking. Error reads:

Error 13 The "LinkAssemblies" task failed unexpectedly.
Mono.Cecil.ResolutionException: Failed to resolve System.Diagnostics.TraceEventCache
at Mono.Linker.Steps.MarkStep.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()
at Mono.Linker.Steps.MarkStep.Process()
at Mono.Linker.Steps.MarkStep.Process(LinkContext context)
at Mono.Linker.Pipeline.Process(LinkContext context)
at MonoDroid.Tuner.Linker.Process(LinkerOptions options, LinkContext& context)
at Xamarin.Android.Tasks.LinkAssemblies.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.d__20.MoveNext() gap_android_xamarin

I can't find any reference to this anywhere on the web. Any ideas or thoughts as to what might be causing it?

My app is a relatively simple one (5 Activities + 1 Service), not using anything particularly remarkable.

Any suggestions as to what to try very welcome..!

Chris.

Posts

  • JGoldbergerJGoldberger USMember, Forum Administrator, Xamarin Team, University Xamurai

    Hi Chris,

    So it will deploy to a simulator, correct?

    Have you tried deploying to device in both debug and release mode?

    Jon

  • ChrisLaceyChrisLacey CZMember

    Hi Jon,

    Sorry for delayed response.

    No, it won't deploy to the simulator or a device (or even Build) in Release mode... unless I disable the Linking entirely.

    Still no further forward in determining what might be causing it... and consequently having to live with enormous package sizes :-(

    Chris.

  • JGoldbergerJGoldberger USMember, Forum Administrator, Xamarin Team, University Xamurai

    Hey Chris,

    Can you build and deploy a simple Hello World app?

  • ChrisLaceyChrisLacey CZMember

    Good call, Jgoldberger.

    Yes, I can Link a simple Hello World. The linking failure only kicks in when I reference JSON.Net (Newtonsoft.Json.dll)

    Looking at the forums again now, this looks like it might be an instance of the same issue reported at http://forums.xamarin.com/discussion/6441/problem-with-linking

    (So probably I should be keeping quiet and awaiting an update...!)

  • I succeed to solve the problem.
    Compile the NewtonSoft.Json and remove TraceEventCache from the file DiagnosticsTraceWriter.cs

    as follows:
    ///


    /// Writes the specified trace level, message and optional exception.
    ///

    ///

    The at which to write this trace.
    /// The trace message.
    /// The trace exception. This parameter is optional.
    public void Trace(TraceLevel level, string message, Exception ex)
    {
    if (level == TraceLevel.Off)
    return;
            //TraceEventCache eventCache = new TraceEventCache();
            //TraceEventType traceEventType = GetTraceEventType(level);
    
            //foreach (TraceListener listener in DiagnosticsTrace.Listeners)
            //{
            //    if (!listener.IsThreadSafe)
            //    {
            //        lock (listener)
            //        {
            //            listener.TraceEvent(eventCache, "Newtonsoft.Json", traceEventType, 0, message);
            //        }
            //    }
            //    else
            //    {
            //        listener.TraceEvent(eventCache, "Newtonsoft.Json", traceEventType, 0, message);
            //    }
    
            //    if (DiagnosticsTrace.AutoFlush)
            //        listener.Flush();
            //}
        }
    
  • Hi Everyone,

    Also a different solution is to download a compiled Newtonsoft.JSON component from the components store (its free) and use that one for release. It solved the issue without any repackaging :D

    Hope it helps,

Sign In or Register to comment.