Linking issue.

UseriusUserius AUMember

I am using FusedLocationApi in my app to get the current location. It compiles fine. It all works fine in Debug with "Don't Link" option. But in Release mode, when calling GetLastLocation function, I am getting the following error:

Error 3 The "LinkAssemblies" task failed unexpectedly.
Xamarin.Android.XamarinAndroidException: error XA2006: Reference to metadata item 'Android.Support.V4.Internal.View.ISupportMenu' (defined in 'Xamarin.Android.Support.v7.AppCompat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null') from 'Xamarin.Android.Support.v7.AppCompat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' could not be resolved. ---> Mono.Cecil.ResolutionException: Failed to resolve Android.Support.V4.Internal.View.ISupportMenu

Obviously, if I set linking option to "Don't Link" in Release mode, everything works fine. But the result file is huge.

App target is API Level 21, min version is API Level 15.

Any help will be appreciated.

Tagged:

Posts

  • SebastianSeidel.9226SebastianSeidel.9226 DEInsider, University ✭✭✭✭

    Go to Linker Options and add Xamarin.Android.Support.v4 to Ignore assemblies. Does it help?

  • UseriusUserius AUMember

    Thanks, Sebastian. I did try to put this assembly into ignore list, but unfortunately it did not help. I also tried to add Xamarin.Android.Support.v7.AppCompat since error suggests that ISupportMenu is defined there. Did not help either.

  • RiccardoBadiniRiccardoBadini ITMember ✭✭

    Hi guys, I've the same problem and Sebastian's suggestion didn't work for me.
    Did you solve it? Any other suggestions?
    Thanks in advance :)

  • SebastianSeidel.9226SebastianSeidel.9226 DEInsider, University ✭✭✭✭

    Maybe you can try something mentioned here

  • UseriusUserius AUMember

    Unfortunately playing with different linker permutations did not help. I had to give up using FusedLocationApi and get back to LocationService. It might be some bug with Xamarin Linker when dealing with interfaces.

  • UseriusUserius AUMember

    Just to clarify a bit more, this is the full error from the logcat

    Error 3 The "LinkAssemblies" task failed unexpectedly.
    Xamarin.Android.XamarinAndroidException: error XA2006: Reference to metadata item 'Android.Support.V4.Internal.View.ISupportMenu' (defined in 'Xamarin.Android.Support.v7.AppCompat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null') from 'Xamarin.Android.Support.v7.AppCompat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' could not be resolved. ---> Mono.Cecil.ResolutionException: Failed to resolve Android.Support.V4.Internal.View.ISupportMenu
    at Mono.Linker.Steps.MarkStep.MarkType(TypeReference reference)
    at MonoDroid.Tuner.MonoDroidMarkStep.MarkType(TypeReference reference)
    at Mono.Linker.Steps.MarkStep.MarkType(TypeReference reference)
    at MonoDroid.Tuner.MonoDroidMarkStep.MarkType(TypeReference reference)
    at Mono.Linker.Steps.MarkStep.MarkType(TypeReference reference)
    at MonoDroid.Tuner.MonoDroidMarkStep.MarkType(TypeReference reference)
    at Mono.Linker.Steps.MarkStep.MarkType(TypeReference reference)
    at MonoDroid.Tuner.MonoDroidMarkStep.MarkType(TypeReference reference)
    at Mono.Linker.Steps.MarkStep.MarkType(TypeReference reference)
    at MonoDroid.Tuner.MonoDroidMarkStep.MarkType(TypeReference reference)
    at Mono.Linker.Steps.MarkStep.MarkGenericArguments(IGenericInstance instance)
    at Mono.Linker.Steps.MarkStep.GetOriginalType(TypeReference type)
    at Mono.Linker.Steps.MarkStep.MarkType(TypeReference reference)
    at MonoDroid.Tuner.MonoDroidMarkStep.MarkType(TypeReference reference)
    at Mono.Linker.Steps.MarkStep.MarkField(FieldReference reference)
    at Mono.Linker.Steps.MarkStep.InitializeFields(TypeDefinition type)
    at Mono.Linker.Steps.MarkStep.InitializeType(TypeDefinition type)
    at Mono.Linker.Steps.MarkStep.InitializeAssembly(AssemblyDefinition assembly)
    at Mono.Linker.Steps.MarkStep.Initialize()
    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()
    --- End of inner exception stack trace ---
    at Xamarin.Android.Diagnostic.Error(Int32 code, Exception innerException, String message, Object[] args)
    at Xamarin.Android.Tasks.LinkAssemblies.Execute()
    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
    at Microsoft.Build.BackEnd.TaskBuilder.d__20.MoveNext() SalesAttach.Android

    05-22 14:37:34.768: I/MonoDroid(29416): UNHANDLED EXCEPTION:
    05-22 14:37:34.768: I/MonoDroid(29416): Java.Lang.LinkageError: Exception of type 'Java.Lang.LinkageError' was thrown.
    05-22 14:37:34.768: I/MonoDroid(29416): at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () <0x00028>
    05-22 14:37:34.768: I/MonoDroid(29416): at System.Runtime.CompilerServices.AsyncMethodBuilderCore.m__0 (object) <0x0003f>
    05-22 14:37:34.768: I/MonoDroid(29416): at Android.App.SyncContext/c__AnonStorey0.<>m__0 () <0x00027>
    05-22 14:37:34.768: I/MonoDroid(29416): at Java.Lang.Thread/RunnableImplementor.Run () <0x0003f>
    05-22 14:37:34.768: I/MonoDroid(29416): at Java.Lang.IRunnableInvoker.n_Run (intptr,intptr) <0x0003b>
    05-22 14:37:34.768: I/MonoDroid(29416): at (wrapper dynamic-method) object.9542915e-8d1b-4eed-854d-d23e69438fc1 (intptr,intptr) <0x0003b>
    05-22 14:37:34.768: I/MonoDroid(29416): --- End of managed exception stack trace ---
    05-22 14:37:34.768: I/MonoDroid(29416): java.lang.NoSuchMethodError: no method with name='getLastLocation' signature='(Lcom/google/android/gms/common/api/GoogleApiClient;)Landroid/location/Location;' in class Lcom/google/android/gms/internal/nf;
    05-22 14:37:34.768: I/MonoDroid(29416): at dalvik.system.NativeStart.run(Native Method)
    05-22 14:37:35.206: D/dalvikvm(29416): GC_CONCURRENT freed 3231K, 26% free 11772K/15724K, paused 9ms+8ms, total 82ms

  • IanDawsonIanDawson GBMember ✭✭

    Bumpity bump.
    Just trying to create a release version of my app and having exactly the same problem.

    I'm afraid I have nothing helpful to add but just want to draw this to the attention of the xamarin folks that this is a becoming an issue.

  • AndrewCheongAndrewCheong USMember

    Yes I'm having this issue as well unfortunately.

  • Parth2651Parth2651 USMember

    I was having same error but resolved after below nuget package update
    -Xamarin Support Library v7 AppCompat
    -Xamarin Support Library v7 MediaRouter

  • CaitlinCaitlin USMember ✭✭

    I am having this issue, but only after adding Xamarin.Forms.Maps. I don't know how to fix it, but it may be useful information.

  • CaitlinCaitlin USMember ✭✭

    So I found a solution to this problem, although it may not be enough. If you go to your droid solution properties -> android options select the build configuration that is failing, and select the linker tab. Then set linking to none. This solved my issue.

  • @Parth2651 was right, after updating -Xamarin Support Library v7 AppCompat
    & Xamarin Support Library v7 MediaRouter issue was fixed

  • KeithRomeKeithRome USUniversity ✭✭

    Which version did you update to that resolved the problem? The current release is 22.2.1.0, which has the bug.

    I am currently handling this error case by trapping LinkageError exceptions when calling FusedLocationApi.GetLastLocation() and gracefully downgrading functionality. Hardly ideal. It looks like the last update to this package was two months ago but there are some pre-release versions.

  • MikeGottliebMikeGottlieb USMember

    Is this actually resolved? I'm seeing this now using the 23.3.0 versions of AppCompat. I have tried all of the possible linking settings and also tried enabling and disabling ProGuard. I see the following crash in HockeyApp

    Xamarin caused by: java.lang.NoSuchMethodError: no non-static method "Lcom/google/android/gms/location/internal/zzd;.getLastLocation(Lcom/google/android/gms/common/api/GoogleApiClient;)Landroid/location/Location;"
    md5270abb39e60627f0f200893b490a1ade.ButtonRenderer_ButtonClickListener.n_onClick(Native Method)
    md5270abb39e60627f0f200893b490a1ade.ButtonRenderer_ButtonClickListener.onClick()ButtonRenderer_ButtonClickListener.java:30
    android.view.View.performClick()View.java:5609
    android.view.View$PerformClick.run()View.java:22262
    android.os.Handler.handleCallback()Handler.java:751
    android.os.Handler.dispatchMessage()Handler.java:95
    android.os.Looper.loop()Looper.java:154
    android.app.ActivityThread.main()ActivityThread.java:6077
    java.lang.reflect.Method.invoke(Native Method)
    com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run()ZygoteInit.java:865
    com.android.internal.os.ZygoteInit.main()ZygoteInit.java:755
    
  • MarwatMarwat PKMember ✭✭

    @SebastianSeidel.9226 said:
    Go to Linker Options and add Xamarin.Android.Support.v4 to Ignore assemblies. Does it help?

    Yes this is helpful for me.

Sign In or Register to comment.