android Unity Firebase“无法加载默认应用程序的选项”错误

cnh2zyt3  于 2022-12-09  发布在  Android
关注(0)|答案(8)|浏览(240)

When I run the app this error pops up:
Unable to load options for default app ([D:/Projects/Unity/‏‏PullApp/Assets/StreamingAssets\google-services-desktop.json, D:/Projects/Unity/‏‏PullApp/Assets/StreamingAssets\google-services.json] are missing or malformed) UnityEngine.Debug:LogError(Object) Firebase.Platform.FirebaseLogger:LogMessage(PlatformLogLevel, String) (at Z:/tmp/tmp.4oHf4jn9P6/firebase/app/client/unity/src/Unity/FirebaseLogger.cs:19) Firebase.FirebaseApp:LogMessage(LogLevel, String) (at Z:/tmp/tmp.n6hJS53AxW/firebase/app/client/unity/proxy/FirebaseApp.cs:90) Firebase.AppUtilPINVOKE:FirebaseApp_CreateInternal__SWIG_0() Firebase.FirebaseApp:CreateInternal() (at Z:/tmp/tmp.n6hJS53AxW/firebase/app/client/unity/proxy/FirebaseApp.cs:976) Firebase.FirebaseApp:m__0() (at Z:/tmp/tmp.n6hJS53AxW/firebase/app/client/unity/proxy/FirebaseApp.cs:144) Firebase.FirebaseApp:CreateAndTrack(CreateDelegate, FirebaseApp) (at Z:/tmp/tmp.n6hJS53AxW/firebase/app/client/unity/proxy/FirebaseApp.cs:537) Firebase.FirebaseApp:Create() (at Z:/tmp/tmp.n6hJS53AxW/firebase/app/client/unity/proxy/FirebaseApp.cs:144) Firebase.FirebaseApp:get_DefaultInstance() (at Z:/tmp/tmp.n6hJS53AxW/firebase/app/client/unity/proxy/FirebaseApp.cs:116) DBManager:InitializeFirebase() (at Assets/Scripts/DBManager.cs:30) DBManager:b__0_0(Task`1) (at Assets/Scripts/DBManager.cs:17) System.Threading._ThreadPoolWaitCallback:PerformWaitCallback()
It already worked perfectly on this project, and I don't know what I did that changed it (I can't use Ctrl+Z cause I've closed the app several times since it happened in trying to fix this..) I've already tried to delete all the assets related to firebase and re-import them, still the same error occurs. Also, When I press the error it self, it leds me the this line in my code:

FirebaseApp app = FirebaseApp.DefaultInstance;

tho it's the default line of firebase it self so..
Please help me. I've tried everything and I'm stuck :/

iswrvxsc

iswrvxsc1#

在我的情况下,特殊的签名文件路径造成了这个错误!

qyswt5oh

qyswt5oh2#

google-services json文件应命名为“google-services”。其他名称(如“google-services(1)”)将给予错误。

0yycz8jy

0yycz8jy3#

google-services文件应放置在AsseStreamingAssets文件夹中,这样就解决了问题。

rt4zxlrg

rt4zxlrg4#

我也遇到过这个问题,因为项目名称和路径是中文的,这导致了初始化失败

nuypyhwy

nuypyhwy5#

它表示“[D:/Projects/Unity/PullApp/Assets/StreamingAssets\google-services-desktop.json,D:/Projects/Unity/PullApp/Assets/StreamingAssets\google-services.json]丢失或格式错误”。
您需要将google-services.json放到Assets文件夹中(根据文档,您可以将Firebase配置文件放在Assets文件夹中的任何位置)。
如果您同时注册Unity项目的iOS和Android构建目标,则需要下载并添加两个平台的配置文件。
https://firebase.google.com/docs/unity/setup

0ve6wy6x

0ve6wy6x6#

嗯,似乎没有什么工作,所以我已经创建了一个新的项目从头开始,并重新附加到firebase,现在它的工作完全好。

jaxagkaj

jaxagkaj7#

我刚刚遇到了这个错误,发现我的编辑器创建了google-services.json.txt而不是google-services.json
我建议在VisualStudio之类的工具中打开文件,以防Windows也向您隐藏扩展。

klsxnrf1

klsxnrf18#

在我的例子中,我只是将Google-Services JSON文件添加到Assets文件夹中的另一个名为“StreamingAssets”的文件夹中,错误就消失了!

相关问题