最近公司項目需要接入google的firebase sdk,來更好的分析用戶行為。接入流程到firebase官網選擇unity項目按照流程走就好了。接入完后出現了幾個錯誤
錯誤一
Generation of the Firebase Android resource file google-services.xml from Assets/google-services.json failed.
If you have not included a valid Firebase Android resources in your app it will fail to initialize.
`F:/unity/50_Shopping_Island/../Assets/Firebase/Editor/generate_xml_from_google_services_json.exe -i "Assets/google-services.json" -l`.
Error loading Python DLL: C:\Users\ftb\AppData\Local\Temp\_MEI59722\python27.dll (error code 14001)
說是firebase初始化失敗了,因為下載Python DLL失敗。在網上查了一圈,似乎是因為win7系統和python版本的問題。最后找到了一個很好的解決方案。用pyinstaller重建generate_xml_from_google_services_json.py腳本。
解決步驟
-
確保python環境變量已經配置好
-
創建一個空文件夾,將項目路徑\Assets\Firebase\Editor\下的generate_xml_from_google_services_json.py文件復制到空文件夾下。
-
打開generate_xml_from_google_services_json.py文件,添加這兩行
-
在這個文件夾下啟動命令行工具,執行pip install pyinstaller命令
-
執行以下命令
pyinstaller --clean --win-private-assemblies -F generate_xml_from_google_services_json.py
錯誤二
如果按照官方流程的話,可能還會出現一個錯誤,無法找到google-services.json文件中的一個字段。
Generation of the Firebase Android resource file google-services.xml from Assets/Firebase/GoogleService-Info.plist failed.
If you have not included a valid Firebase Android resources in your app it will fail to initialize.
"python" "/Users/xxxxx/Documents/ProgrammingCloud/Unity/yyyyy/Assets/Firebase/Editor/generate_xml_from_google_services_json.py" -i "Assets/Firebase/GoogleService-Info.plist" -l --plist
Could not find key in plist file: [DATABASE_URL]
You can start to diagnose this issue by executing ""python" "/Users/xxxxx/Documents/ProgrammingCloud/Unity/yyyyy/Assets/Firebase/Editor/generate_xml_from_google_services_json.py" -i "Assets/Firebase/GoogleService-Info.plist" -l --plist" from the command line.