Android 使用Firebase Google Analytics SDK构建Unity项目失败:“;无法加载文件或程序集';UnityEditor.iOS.Extensions.Xcode“; 问题

Android 使用Firebase Google Analytics SDK构建Unity项目失败:“;无法加载文件或程序集';UnityEditor.iOS.Extensions.Xcode“; 问题,android,firebase,unity3d,google-analytics,google-analytics-firebase,Android,Firebase,Unity3d,Google Analytics,Google Analytics Firebase,我正在尝试将Firebase Google Analytics集成到我现有的Unity项目(iOS和Android手机游戏)中。我按照上的说明操作(所有先决条件都已满足)。不幸的是,在尝试在Windows上构建Android版本时,我遇到以下错误: BadImageFormatException: Could not resolve field token 0x040000dc, due to: Could not load type of field 'Firebase.Editor.Xcod

我正在尝试将Firebase Google Analytics集成到我现有的Unity项目(iOS和Android手机游戏)中。我按照上的说明操作(所有先决条件都已满足)。不幸的是,在尝试在Windows上构建Android版本时,我遇到以下错误:

BadImageFormatException: Could not resolve field token 0x040000dc, due to: Could not load type of field 'Firebase.Editor.XcodeProjectModifier:projectInfoDoc' (2) due to: Could not load file or assembly 'UnityEditor.iOS.Extensions.Xcode, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. assembly:UnityEditor.iOS.Extensions.Xcode, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null type:<unknown type> member:(null) signature:<none> assembly:C:\Users\mform\Code\guessme\Assets\Firebase\Editor\Firebase.Editor.dll type:XcodeProjectModifier member:(null) signature:<none>
System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <567df3e0919241ba98db88bec4c6696f>:0)
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <567df3e0919241ba98db88bec4c6696f>:0)
System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at <567df3e0919241ba98db88bec4c6696f>:0)
UnityEditor.Build.BuildPipelineInterfaces+AttributeCallbackWrapper.OnPostprocessBuild (UnityEditor.Build.Reporting.BuildReport report) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/BuildPipelineInterfaces.cs:158)
UnityEditor.Build.BuildPipelineInterfaces+<OnBuildPostProcess>c__AnonStorey2.<>m__1 (UnityEditor.Build.IPostprocessBuildWithReport bpp) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/BuildPipelineInterfaces.cs:398)
UnityEditor.Build.BuildPipelineInterfaces.InvokeCallbackInterfacesPair[T1,T2] (System.Collections.Generic.List`1[T] oneInterfaces, System.Action`1[T] invocationOne, System.Collections.Generic.List`1[T] twoInterfaces, System.Action`1[T] invocationTwo, System.Boolean exitOnFailure) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/BuildPipelineInterfaces.cs:356)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr) (at C:/buildslave/unity/build/Modules/IMGUI/GUIUtility.cs:179)

Error building Player: BadImageFormatException: Could not resolve field token 0x040000dc, due to: Could not load type of field 'Firebase.Editor.XcodeProjectModifier:projectInfoDoc' (2) due to: Could not load file or assembly 'UnityEditor.iOS.Extensions.Xcode, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. assembly:UnityEditor.iOS.Extensions.Xcode, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null type:<unknown type> member:(null) signature:<none> assembly:C:\Users\mform\Code\guessme\Assets\Firebase\Editor\Firebase.Editor.dll type:XcodeProjectModifier member:(null) signature:<none>
BadImageFormatException:无法解析字段标记0x04000DC,原因是:无法加载字段“Firebase.Editor.XcodeProjectModifier:ProjectInfo文档”的类型(2),原因是:无法加载文件或程序集“UnityEdit.iOS.Extensions.Xcode,版本=1.0.0.0,区域性=中性,PublicKeyToken=null”或其依赖项之一。程序集:UnityEditor.iOS.Extensions.Xcode,版本=1.0.0.0,区域性=中性,PublicKeyToken=null类型:成员:(null)签名:程序集:C:\Users\mform\Code\guessme\Assets\Firebase\Editor\Firebase.Editor.dll类型:XcodeProjectModifier成员:(null)签名:
System.Reflection.MonMethod.Invoke(System.Object obj、System.Reflection.BindingFlags invokeAttr、System.Reflection.Binder Binder、System.Object[]参数、System.Globalization.CultureInfo区域性)(位于:0)
Rethrow as TargetInvocationException:调用的目标已引发异常。
System.Reflection.MonMethod.Invoke(System.Object obj、System.Reflection.BindingFlags invokeAttr、System.Reflection.Binder Binder、System.Object[]参数、System.Globalization.CultureInfo区域性)(位于:0)
System.Reflection.MethodBase.Invoke(System.Object obj,System.Object[]参数)(位于:0)
UnityEditor.Build.BuildPipelineInterfaces+AttributeCallbackWrapper.OnPostprocessBuild(UnityEditor.Build.Reporting.BuildReport报告)(位于C:/buildslave/unity/Build/Editor/Mono/BuildPipeline/BuildPipelineInterfaces.cs:158)
UnityEditor.Build.BuildPipelineInterfaces+c__Anostorey2.m__1(UnityEditor.Build.IPostprocessBuildWithReport bpp)(位于c:/buildslave/unity/Build/Editor/Mono/BuildPipeline/BuildPipelineInterfaces.cs:398)
UnityEdit.Build.BuildPipelineInterfaces.InvokeCallbackInterfacesPair[T1,T2](System.Collections.Generic.List`1[T]oneInterfaces,System.Action`1[T]InvokionOne,System.Collections.Generic.List`1[T]twoInterfaces,System.Action`1[T]InvokionTwo,System.Boolean exitOnFailure)(位于C:/buildslave/unity/build/Editor/Mono/BuildPipeline/BuildPipelineInterfaces.cs:356)
GUIUtility:ProcessEvent(Int32,IntPtr)(位于C:/buildslave/unity/build/Modules/IMGUI/GUIUtility.cs:179)
生成播放机时出错:BadImageFormatException:无法解析字段标记0x04000DC,原因是:无法加载字段“Firebase.Editor.XcodeProjectModifier:ProjectInfo文档”(2)的类型由于以下原因:无法加载文件或程序集“UnityEditor.iOS.Extensions.Xcode,Version=1.0.0,Culture=neutral,PublicKeyToken=null”或其依赖项之一。程序集:UnityEditor.iOS.Extensions.Xcode,Version=1.0.0.0,Culture=neutral,PublicKeyToken=null类型:成员:(null)签名:程序集:C:\Users\mform\Code\guessme\Assets\Firebase\Editor\Firebase.Editor.dll类型:XcodeProjectModifier成员:(null)签名:
我不明白为什么它试图加载这个程序集,这显然只适用于iOS。我也不知道如何防止它或摆脱这个bug

设置
  • Windows10Pro
  • 使用Android/iOS版本的现有Unity项目
  • 统一2019.2.16f1
  • 使用Unity打包的OpenJDK和Android SDK/NDK
    • OpenJDK1.8
    • Android SDK工具29.0.2
  • 当前依赖项(全部按预期工作)
  • 我添加了谷歌分析,如中所述
    • 我完成了所有的步骤
    • 在编辑器中执行时,将调用CheckAndFixDependenciesAsync continuation,Firebase依赖项状态为“可用”
生成设置

播放器设置

解决方案尝试
  • 我通过Git重置了所有更改,并从一开始就重新开始了这些步骤,重新导入了SDK unity包
  • 使用播放服务解析器
    • 我更新了版本处理程序
    • 我强制解决了Android依赖项(有效)
  • 已删除库文件夹并重新生成

不幸的是,所有这些都没有起到作用。我非常感谢任何指向正确方向的指针。

感谢(感谢1000次)我在Unity editor中安装了iOS模块(尽管我只是尝试在Windows上构建Android版本).安装了iOS模块后,Android版本就可以运行了。

多亏了Unity editor中的提示(感谢1000次),我才在Unity editor中安装了iOS模块(尽管我只是尝试在Windows上构建Android版本)。安装了iOS模块后,安卓构建工作正常。

切换到iOS平台,构建,然后切换回安卓平台,再次构建。非常感谢@Cœur!我在Windows上构建,甚至没有启用iOS支持。安装Unity iOS模块后,安卓构建工作正常!问题解决。切换到iOS平台,构建,然后切换回Android平台并重新构建。非常感谢@Cœur!我在Windows上构建,甚至没有启用iOS支持。安装Unity iOS模块后,Android构建工作正常!问题解决了。你也可以相信,正如他回答的那样,但他的回答由于格式的原因被删除(类似于“你试过[…]iOS吗?”).在我自己的例子中,在为macOS构建时,我遇到了与Unity类似的问题,我必须切换到iOS,然后切换回macOS以使其正常工作。好吧,如果我的一位开发人员编写了一段需要iOS支持平台的代码,而你想为Android编译,我会解雇他^^^^这是一个很好的垃圾代码背后的例子。.谷歌处于最佳状态?你也可以相信