Failed to resolve Android.Gms.Common.Zzc in Release

Stesvis 1,041 Reputation points
2021-01-26T20:50:02.903+00:00

I have a problem when I build this app in RELEASE mode only.
In debug it works no problem, but in release I get this build error and I can't figure out what it could be..

Any idea?

Severity Code Description Project File Line Suppression State
Error Java.Interop.Tools.Diagnostics.XamarinAndroidException: error XA2006: Could not resolve reference to 'Android.Gms.Common.Zzc' (defined in assembly 'Xamarin.GooglePlayServices.Base, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null') with scope 'Xamarin.GooglePlayServices.Basement, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. When the scope is different from the defining assembly, it usually means that the type is forwarded. ---> Mono.Cecil.ResolutionException: Failed to resolve Android.Gms.Common.Zzc
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.MarkType(TypeReference reference)
at MonoDroid.Tuner.MonoDroidMarkStep.MarkType(TypeReference reference)
at Mono.Linker.Steps.MarkStep.MarkField(FieldDefinition field)
at Mono.Linker.Steps.MarkStep.MarkEntireType(TypeDefinition type)
at Mono.Linker.Steps.MarkStep.MarkEntireAssembly(AssemblyDefinition assembly)
at Mono.Linker.Steps.MarkStep.InitializeAssembly(AssemblyDefinition assembly)
at Mono.Linker.Steps.MarkStep.Initialize()
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)
--- End of inner exception stack trace ---
at Java.Interop.Tools.Diagnostics.Diagnostic.Error(Int32 code, Exception innerException, String message, Object[] args) in /Users/builder/azdo/_work/30/s/xamarin-android/external/Java.Interop/src/Java.Interop.Tools.Diagnostics/Java.Interop.Tools.Diagnostics/Diagnostic.cs:line 166
at Xamarin.Android.Tasks.LinkAssemblies.Execute(DirectoryAssemblyResolver res)
at Xamarin.Android.Tasks.LinkAssemblies.RunTask()
at Xamarin.Android.Tasks.AndroidTask.Execute() Tradeality.Mobile.Android

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,302 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. JessieZhang-MSFT 7,706 Reputation points Microsoft Vendor
    2021-01-27T07:20:10.373+00:00

    Hello,

    Welcome to our Microsoft Q&A platform!

    You can try to set the linker option to None. This helps to narrow down the scope of our problem.

    60775-image.png

    For more details, you can check document : Configure the Linker.

    But if you release your apk to app store, it is recommended that you set the linker to the first one: `Sdk Assemblies Only`` .

    Of course, if you set the Linker Configuration to None, the apk will be very large, but you can also use Custom Linker Configuration to tell the linker to stop removing certain assemblies, and/or methods.

    To do this, you need to define an XML file with the top-level element <linker> which contains assembly nodes which in turn contain type nodes, which in turn contain method and field nodes.

    For more details, you can check document :

    https://learn.microsoft.com/en-us/xamarin/cross-platform/deploy-test/linker

    https://www.xamarinhelp.com/xamarin-linker/

    Best Regards,

    Jessie Zhang


    If the response is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

  2. Simon Wainwright 1 Reputation point
    2021-01-28T11:36:37.31+00:00

    I had this same issue yesterday and managed to resolve it by doing the following:

    Changed Linking to be None (built successfully after that but would not deploy to my device)
    Changed Linking back to SDK
    (I've no idea if the above had anything to do with getting it working again)

    Ensured the Xamarin.Google.* Nuget packages were all up to date and the same (v71.* for me)
    Deleted Bin and Obj folders
    Restarted VS

    Then i could build and deploy with linked SDK assemblies

    0 comments No comments