使用 Firebase Google Analytics SDK 构建 Unity 项目失败:"Could not load file or assembly 'UnityEditor.iOS.Extensions.Xcode"
Building Unity project with Firebase Google Analytics SDK fails: "Could not load file or assembly 'UnityEditor.iOS.Extensions.Xcode"
问题
我正在尝试将 Firebase Google Analytics 集成到我现有的 Unity 项目(iOS 和 Android 的手机游戏)。我正在按照 https://firebase.google.com/docs/unity/setup 上的说明进行操作(所有先决条件都已满足)。不幸的是,当我尝试在 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>
我不明白为什么它会尝试加载这个程序集,它显然只用于 iOS。而且我不知道如何防止它或摆脱这个错误。
设置
- Windows 10 专业版
- 具有工作 Android/iOS 构建的现有 Unity 项目
- Unity 2019.2.16f1
- 使用 OpenJDK 和 Android SDK/NDK 与 Unity 一起打包
- OpenJDK 1.8
- Android SDK 工具 29.0.2
- 当前依赖项(都按预期工作)
- 我添加了 Google 分析,如 https://firebase.google.com/docs/unity/setup 中所述
- 我完成了所有步骤
- 在编辑器中执行时,将调用 CheckAndFixDependenciesAsync 延续,Firebase 依赖状态为 "Available"
构建设置
播放器设置
解决方案尝试
- 我通过Git重置了所有更改并从头开始重新执行这些步骤,重新导入SDK统一包
- 使用播放服务解析器
- 我更新了版本处理程序
- 我强制解决了 Android 依赖项(有效)
- 删除了 Library 文件夹并重建
不幸的是,None 其中有帮助。如果有任何指向正确方向的指示,我将不胜感激。
感谢 @Cœur 的提示(感谢 1000 次)我在 Unity 编辑器中安装了 iOS 模块(尽管我只是想构建 Android 版本在 Windows 上)。安装 iOS 模块后,Android 构建工作正常。
问题
我正在尝试将 Firebase Google Analytics 集成到我现有的 Unity 项目(iOS 和 Android 的手机游戏)。我正在按照 https://firebase.google.com/docs/unity/setup 上的说明进行操作(所有先决条件都已满足)。不幸的是,当我尝试在 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>
我不明白为什么它会尝试加载这个程序集,它显然只用于 iOS。而且我不知道如何防止它或摆脱这个错误。
设置
- Windows 10 专业版
- 具有工作 Android/iOS 构建的现有 Unity 项目
- Unity 2019.2.16f1
- 使用 OpenJDK 和 Android SDK/NDK 与 Unity 一起打包
- OpenJDK 1.8
- Android SDK 工具 29.0.2
- 当前依赖项(都按预期工作)
- 我添加了 Google 分析,如 https://firebase.google.com/docs/unity/setup 中所述
- 我完成了所有步骤
- 在编辑器中执行时,将调用 CheckAndFixDependenciesAsync 延续,Firebase 依赖状态为 "Available"
构建设置
播放器设置
解决方案尝试
- 我通过Git重置了所有更改并从头开始重新执行这些步骤,重新导入SDK统一包
- 使用播放服务解析器
- 我更新了版本处理程序
- 我强制解决了 Android 依赖项(有效)
- 删除了 Library 文件夹并重建
None 其中有帮助。如果有任何指向正确方向的指示,我将不胜感激。
感谢 @Cœur 的提示(感谢 1000 次)我在 Unity 编辑器中安装了 iOS 模块(尽管我只是想构建 Android 版本在 Windows 上)。安装 iOS 模块后,Android 构建工作正常。