2

i work on Firebase integration into test Android project in Unity. I need to setup the FirebaseApp instance from code, because i would like to switch between development and production containers according to some conditions. I use this block of code to initialize FirebaseApp. This code is called before any other Firebase related code.

    Firebase.AppOptions opts = new Firebase.AppOptions();
    opts.ApiKey = "AI......M";
    opts.AppId = "1:.....01";
    opts.MessageSenderId = "18....7";

    Firebase.FirebaseApp.Create(opts);

But if in the project has no google-services.xml then it crash in some internal native code, probably on mission configuration file, because with it and without custom opts it works fine. And if the app has the google-services.xml file and opts are used then it logs this message:

AppOptions will be ignored as the default app has already been initialized.  To disable automatic app initialization remove or rename resources derived from google-services.json.

I am pretty sure that FirebaseApp.Create(opts) is the first Firebase call.

So could someone help me, how to initialize default FirebaseApp with custom options? Or does anyone know how to call for example Analytics.SendEvent on different FirebaseApp instance in Unity wrapper? (Created by FirebaseApp.Create(opts, "someInstance"); )

  • Have you tried removing the folder Plugins/Android/Firebase/res? – Juan Bayona Beriso Feb 28 '17 at 14:22
  • I tried now, but still crashing in native. :(. I also found this post: [Can I initialize Firebase without using google-services.json](http://stackoverflow.com/questions/38962025/can-i-initialize-firebase-without-using-google-services-json) and same result (crash). – Matěj Mainuš Mar 01 '17 at 10:54

0 Answers0