Firebase Unity SDK无法找到所需的命令行工具python,该工具用于生成Firebase Android资源。

9

当我使用Firebase SDK 8.7.0打开Unity时,会出现以下错误。

Unable to find command line tool python required for Firebase Android resource generation.
python is required to generate the Firebase Android resource file google-services.xml from Assets/Firebase/GoogleService-Info.plist. Without Firebase Android resources, your app will fail to initialize.
python was distributed with each Firebase Unity SDK plugin, was it deleted?

System.ComponentModel.Win32Exception (0x80004005): ApplicationName='python', CommandLine='"/Users/xxx/Documents/unity-project/Assets/Firebase/Editor/generate_xml_from_google_services_json.py" -i "Assets/Firebase/GoogleService-Info.plist" -l --plist', CurrentDirectory='/Users/xxx/Documents/unity-project', Native error= mono-io-layer-error (2)
  at System.Diagnostics.Process.StartWithCreateProcess (System.Diagnostics.ProcessStartInfo startInfo) [0x002dc] in <0463b2ef957545c0a51b42f372cd4fbb>:0 
  at System.Diagnostics.Process.Start () [0x0003a] in <0463b2ef957545c0a51b42f372cd4fbb>:0 
  at (wrapper remoting-invoke-with-check) System.Diagnostics.Process.Start()
  at GooglePlayServices.CommandLine.RunViaShell (System.String toolPath, System.String arguments, System.String workingDirectory, System.Collections.Generic.Dictionary`2[TKey,TValue] envVars, GooglePlayServices.CommandLine+IOHandler ioHandler, System.Boolean useShellExecution, System.Boolean stdoutRedirectionInShellMode) [0x002dc] in Z:\tmp\tmp.cvthQg1D2s\third_party\unity\unity_jar_resolver\source\AndroidResolver\src\CommandLine.cs:631 
  at GooglePlayServices.CommandLine.Run (System.String toolPath, System.String arguments, System.String workingDirectory, System.Collections.Generic.Dictionary`2[TKey,TValue] envVars, GooglePlayServices.CommandLine+IOHandler ioHandler) [0x00000] in Z:\tmp\tmp.cvthQg1D2s\third_party\unity\unity_jar_resolver\source\AndroidResolver\src\CommandLine.cs:510 
  at Firebase.Editor.PythonExecutor.Run (System.Collections.Generic.IEnumerable`1[T] arguments, System.String workingDirectory, System.Collections.Generic.Dictionary`2[TKey,TValue] envVars, GooglePlayServices.CommandLine+IOHandler ioHandler) [0x00000] in Z:\tmp\tmp.dYyxJerQE9\firebase\app\client\unity\editor\src\PythonExecutor.cs:180 
  at Firebase.Editor.GenerateXmlFromGoogleServicesJson.RunResourceGenerator (System.Collections.Generic.IEnumerable`1[T] arguments, System.String inputPath, System.Boolean showCommandLine) [0x0001b] in Z:\tmp\tmp.dYyxJerQE9\firebase\app\client\unity\editor\src\GenerateXmlFromGoogleServicesJson.cs:521 
 #0 GetStacktrace(int)
 #1 DebugStringToFile(DebugStringToFileData const&)
 #2 DebugLogHandler_CUSTOM_Internal_Log(LogType, LogOption, ScriptingBackendNativeStringPtrOpaque*, ScriptingBackendNativeObjectPtrOpaque*)
 #3  (Mono JIT Code) (wrapper managed-to-native) UnityEngine.DebugLogHandler:Internal_Log (UnityEngine.LogType,UnityEngine.LogOption,string,UnityEngine.Object)
 #4  (Mono JIT Code) [Z:\tmp\tmp.dYyxJerQE9\firebase\app\client\unity\editor\src\GenerateXmlFromGoogleServicesJson.cs:407] Firebase.Editor.GenerateXmlFromGoogleServicesJson:ReadBundleIds (string)

我尝试在shell中运行python "/Users/xxx/Documents/unity-project/Assets/Firebase/Editor/generate_xml_from_google_services_json.py" -i "Assets/Firebase/GoogleService-Info.plist" -l --plist,它成功输出了我的应用程序的捆绑标识符com.myapp.bundle

我还尝试重新导入Firebase SDK、重启Unity和Mac,但它们都没有解决问题。

我搜索了类似的问题,但不幸的是没有找到解决方案。

在这个错误出现之前,我做了一些事情:我升级了macOS到最新的Monterey 12.3。不确定是否有关联。

我会感激任何帮助。我已经在这上面花了整整一天了,非常绝望。


请澄清您的具体问题或提供额外的细节,以准确突出您所需的内容。目前的描述不够清晰,很难确定您在询问什么。 - Community
2个回答

10
由于MacOS 12.3移除了Python2,所以出现了这个问题。很遗憾,目前我没有任何解决方法。我尝试将Python3符号链接到/usr/local/bin(请确保它在您的路径上),在终端中可以正常工作,但是出于某种原因,Unity/Firebase仍然无法访问它。我还尝试进入恢复模式并禁用SIP,但由于 Monterey(和Big Sur)中现在已经是只读文件,所以你仍然不能将其符号链接到/usr/bin。我已经向此问题添加了一些注释 - https://github.com/firebase/firebase-unity-sdk/issues/154,并且可能还会在Unity论坛/错误跟踪器上发布,因为我不确定问题是否出现在Firebase SDK中还是Unity本身中。

2
嗨 Dustin,非常感谢您的评论!我会关注该问题链接。幸运的是,构建仍然成功,并且 Firebase 也可以正常工作,即使它显示错误,所以现在它只是一个错误垃圾邮件。不确定在项目中进行新更改是否会导致其出现故障。 - etleoking
你有没有碰巧找到解决方法? - xySVerma
这是一个临时解决方案的链接(未经测试):https://github.com/firebase/firebase-unity-sdk/issues/154#issuecomment-1068879556 - etleoking
我非常确定你是指的Mac OS 12.3。你可能想要纠正一下... ;) - loptrinho

3
一个更新:
如果你正在升级到最新的Unity 2021 LTS,在某些情况下(在这个帖子中提到:https://github.com/firebase/quickstart-unity/issues/1228#issuecomment-1098892025),可能会抑制python错误并在编辑器中收到以下无法清除的错误。
Internal build system error. Backend exited with code 2.

如果你遇到这个错误,你需要使用这个第三方修复补丁:https://github.com/techyworm10/firebase-unity-sdk-editor-python-fix
这个方法解决了我的问题。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接