Xamarin:无法解析程序集:'Google.Apis.Core'

Xamarin: Failed to resolve assembly: 'Google.Apis.Core'

我最近在我的 Xamarin 项目(具体来说是一个共享项目)上安装了一些 Google 的 .NET API 客户端库,以便获取与以下内容相关的 YouTube 结果的链接搜索查询。确切地说,我安装的三个 NuGet 包是:

我的应用程序旨在跨平台,因此我确保每个包都安装在 Android 和 iOS 项目上。代码编译得很好,我在每个包中对 类 进行的导入也编译得很好。但是,当我启动编译器时,我收到此错误:

Failed to load assembly from stream: Mono.Cecil.AssemblyResolutionException: Failed to resolve assembly: 'Google.Apis.Core, Version=1.34.0.0, Culture=neutral, PublicKeyToken=4b01fa6e34db77ab'

然后,当我检查整个解决方案的 NuGet window 以查看是否为两个项目安装了包时,三个包中的每一个的框都取消了自己的勾选(即使 .csproj 文件都包含包含每个包的语句)。我不确定这是否是由于不兼容造成的,因为我见过的其他不兼容的软件包根本无法安装。我试过清理解决方案,甚至单独添加包;单独添加它们时,window 显示它们已为每个包安装,但在我下次构建时会抛出相同的错误。

关于问题的一些信息:

为方便起见,此处列出了完整的错误日志。

Failed to load assembly from stream: Mono.Cecil.AssemblyResolutionException: Failed to resolve assembly: 'Google.Apis.Core, Version=1.34.0.0, Culture=neutral, PublicKeyToken=4b01fa6e34db77ab'
at Upsight.LoadedAssemblyResolver.Resolve (Mono.Cecil.AssemblyNameReference name) [0x001e0] in <5a7d391011b47c3aa745038310397d5a>:0 
at Mono.Cecil.MetadataResolver.Resolve (Mono.Cecil.TypeReference type) [0x00038] in <0ea22156f1264b96bf10daa7186c2c1f>:0 
at Mono.Cecil.ModuleDefinition.Resolve (Mono.Cecil.TypeReference type) [0x00014] in <0ea22156f1264b96bf10daa7186c2c1f>:0 
at Mono.Cecil.TypeReference.Resolve () [0x00006] in <0ea22156f1264b96bf10daa7186c2c1f>:0 
at Mono.Cecil.Mixin.CheckedResolve (Mono.Cecil.TypeReference self) [0x00000] in <0ea22156f1264b96bf10daa7186c2c1f>:0 
at Mono.Cecil.SignatureReader.ReadCustomAttributeEnum (Mono.Cecil.TypeReference enum_type) [0x00000] in <0ea22156f1264b96bf10daa7186c2c1f>:0 
at Mono.Cecil.SignatureReader.ReadCustomAttributeElementValue (Mono.Cecil.TypeReference type) [0x0002f] in <0ea22156f1264b96bf10daa7186c2c1f>:0 
at Mono.Cecil.SignatureReader.ReadCustomAttributeElement (Mono.Cecil.TypeReference type) [0x00015] in <0ea22156f1264b96bf10daa7186c2c1f>:0 
at Mono.Cecil.SignatureReader.ReadCustomAttributeFixedArgument (Mono.Cecil.TypeReference type) [0x00015] in <0ea22156f1264b96bf10daa7186c2c1f>:0 
at Mono.Cecil.SignatureReader.ReadCustomAttributeConstructorArguments (Mono.Cecil.CustomAttribute attribute, Mono.Collections.Generic.Collection`1[T] parameters) [0x0002e] in <0ea22156f1264b96bf10daa7186c2c1f>:0 
at Mono.Cecil.MetadataReader.ReadCustomAttributeSignature (Mono.Cecil.CustomAttribute attribute) [0x0003c] in <0ea22156f1264b96bf10daa7186c2c1f>:0 
at Mono.Cecil.CustomAttribute.<Resolve>b__35_0 (Mono.Cecil.CustomAttribute attribute, Mono.Cecil.MetadataReader reader) [0x00000] in <0ea22156f1264b96bf10daa7186c2c1f>:0 
at Mono.Cecil.ModuleDefinition.Read[TItem,TRet] (TItem item, System.Func`3[T1,T2,TResult] read) [0x00029] in <0ea22156f1264b96bf10daa7186c2c1f>:0 
at Mono.Cecil.CustomAttribute.Resolve () [0x00017] in <0ea22156f1264b96bf10daa7186c2c1f>:0 
at Mono.Cecil.CustomAttribute.get_ConstructorArguments () [0x00000] in <0ea22156f1264b96bf10daa7186c2c1f>:0 
at Mono.Cecil.ImmediateModuleReader.ReadCustomAttributes (Mono.Cecil.ICustomAttributeProvider provider) [0x00024] in <0ea22156f1264b96bf10daa7186c2c1f>:0 
at Mono.Cecil.ImmediateModuleReader.ReadProperties (Mono.Cecil.TypeDefinition type) [0x00031] in <0ea22156f1264b96bf10daa7186c2c1f>:0 
at Mono.Cecil.ImmediateModuleReader.ReadType (Mono.Cecil.TypeDefinition type) [0x00068] in <0ea22156f1264b96bf10daa7186c2c1f>:0 
at Mono.Cecil.ImmediateModuleReader.ReadTypes (Mono.Collections.Generic.Collection`1[T] types) [0x0000c] in <0ea22156f1264b96bf10daa7186c2c1f>:0 
at Mono.Cecil.ImmediateModuleReader.ReadModule (Mono.Cecil.ModuleDefinition module, System.Boolean resolve_attributes) [0x0004f] in <0ea22156f1264b96bf10daa7186c2c1f>:0 
at Mono.Cecil.ImmediateModuleReader.<ReadModule>b__2_0 (Mono.Cecil.ModuleDefinition module, Mono.Cecil.MetadataReader reader) [0x00007] in <0ea22156f1264b96bf10daa7186c2c1f>:0 
at Mono.Cecil.ModuleDefinition.Read[TItem,TRet] (TItem item, System.Func`3[T1,T2,TResult] read) [0x00029] in <0ea22156f1264b96bf10daa7186c2c1f>:0 
at Mono.Cecil.ImmediateModuleReader.ReadModule () [0x00000] in <0ea22156f1264b96bf10daa7186c2c1f>:0 
at Mono.Cecil.ModuleReader.CreateModule (Mono.Cecil.PE.Image image, Mono.Cecil.ReaderParameters parameters) [0x0007b] in <0ea22156f1264b96bf10daa7186c2c1f>:0 
at Mono.Cecil.ModuleDefinition.ReadModule (Mono.Disposable`1[T] stream, System.String fileName, Mono.Cecil.ReaderParameters parameters) [0x0000d] in <0ea22156f1264b96bf10daa7186c2c1f>:0 
at Mono.Cecil.ModuleDefinition.ReadModule (System.IO.Stream stream, Mono.Cecil.ReaderParameters parameters) [0x00012] in <0ea22156f1264b96bf10daa7186c2c1f>:0 
at Mono.Cecil.AssemblyDefinition.ReadAssembly (System.IO.Stream stream, Mono.Cecil.ReaderParameters parameters) [0x00000] in <0ea22156f1264b96bf10daa7186c2c1f>:0 
at NInterpret.CecilLoader.loadStreamWithResolver (System.IO.Stream peStream, Mono.Cecil.IAssemblyResolver resolver) [0x0000f] in <5a7d38ec7eef0f2aa7450383ec387d5a>:0 
at <StartupCode$Continuous-Core-Droid>.$LoadedAssemblies+TryLoadAsync@325-4.Invoke (System.Byte[] _arg2) [0x00008] in <5a7d391011b47c3aa745038310397d5a>:0 
at Microsoft.FSharp.Control.AsyncBuilderImpl+args@835-1[a,b].Invoke (a a) [0x00016] in <55b16819904cf4daa74503831968b155>:0

如果有任何方法可以在不使用 Google API 的情况下实现我想要实现的目标,那可能是规避整个问题的最佳方法。然而,我已经在这个概念的 WPF 测试中实现了它,所以如果有一个简单的解决方案,我会很高兴知道它。我将提供任何必要的附加信息,但请注意,我可能无法提供太多帮助,因为我正在了解 Xamarin 的工作原理。

googleapi.net 客户端库不支持 Xarmain 身份验证。

请参阅issue 984