quickstart-unity: Firebase Database 6.16.0 crashes Unity Editor on Install and on Play (with easy fix)
[REQUIRED] Please fill in the following fields:
- Unity editor version: 2019.4.11f
- Firebase Unity SDK version: 6.16.0
- Source you installed the SDK: Unity Package Manager (.unitypackage or Unity Package Manager)
- Problematic Firebase Component: Database
- Other Firebase Components in use: Auth, Crashlytics, Messaging, Functions
- Additional SDKs you are using: Facebook, Leanplum, Amplitude, Branch (does not apply)
- Platform you are using the Unity editor on: Mac
- Platform you are targeting: iOS, Android
- Scripting Runtime: Mono, and/or IL2CPP
[REQUIRED] Please describe the issue here:
After installing Firebase Database version 6.16.0 using Unity Package Manager pressing Play in project which uses Firebase Database crashes the Unity Editor. The Editor also did crash when installing Firebase Database through UPM
In the Unity Editor.Log I can see: ERROR: Could not initialize persistence: Unable to find app data directory.
This seems to be causing the crash.
After looking at the Firebase Database C++ code I found out what was causing this error. It’s quite obvious as the error message can be found in database/src/desktop/core/repo.cc By looking at that file I saw the cause was relating to GetAppDataPath On Mac GetAppDataPath seems to be finding the Application Support directory and appending the package_name to that if that folder exists. It seems to be using package_name for the folder which is according to the xml converter created from the bundle_id.
In my case the bundle_id was: Is.Company.App
Which lead me to the conclusion that Firebase Database was looking for the folder path ~/Library/Application Support/Is.Company.App
That folder did not exists which explained the error.
I therefore created it and after that the Unity Editor ran without crashing and I saw data being created in a subfolder of the folder I just created and no error in Unity logs.
Steps to reproduce:
Install Firebase Database 6.16.0 through Unity Package Manager.
Firebase Database might fail on install.
Create scene and c# files which starts Firebase App.
Press Play and see if crash occurs.
If the Unity Editor crashes then open Unity Editor.Log and look for: ERROR: Could not initialize persistence: Unable to find app data directory.
To fix for MacOS
For Firebase App with bundle id (package_name): Is.Company.App Just create the folder: ~/Library/Application Support/Is.Company.App
mkdir ~/Library/Application\ Support/Is.Company.App
To fix for Windows
For Firebase App with bundle id (package_name): Is.Company.App Just create the folder: C:\Users[username]\AppData\Local\Is.Company.App The folder is in path (see set) such as fx.: LOCALAPPDATA=C:\Users[username]\AppData\Local
mkdir %LOCALAPPDATA%\Is.Company.App
Note
You might need to use upper or lowercase package_name. Just try according to your bundle_id or package_name stated in google-services.json
I did not help to downgrade to 6.15.2 and then install 6.16.0 again.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 18
- Comments: 32 (3 by maintainers)
@bhupiister they have deprecated that function but the documentation has not been updated. Maybe @chkuang-g can push that.
You should use AppOptions instead … check out AppOptions
and how to use it FirebaseApp.Create(AppOptions options)
Created the folder with the same name as bundle ID on windows and it solved my problem! for example, on my PC the path was C:\Users\home\AppData\Local, I then created folder name com.liftcad.cad This solution helped me a lot. Huge thanks to @snorrsi
hi @steve6t6 ,
have you been switching platforms in Unity ?
I ask because the bundle_id / package_name is not always the same for all operating systems. Mine are with upper case and also with only lower case letters, if you have case sensitive disc you might run into issues. Since you are still getting the same error it seems it still Firebase Database can’t find the folder it wants.
The other fallback errors happen all the time for me, not sure about the cause there maybe @chkuang-g can explain those.
@nagibator96 I just updated the description. Just create the folder under %LOCALAPPDATA%