简体   繁体   English

Firebase 多个项目和分析 Android

[英]Firebase Multiple Projects & Analytics Android

I have a project on Firebase in this project i have multiple apps inside it eg different flavors of the app.我在这个项目中有一个关于 Firebase 的项目,里面有多个应用程序,例如不同风格的应用程序。 My question is is there a way to programmatically initailise these apps at runtime i have tried the following from the google firebase docs我的问题是有没有办法在运行时以编程方式初始化这些应用程序我已经尝试了以下来自 google firebase docs 的方法

FirebaseOptions options = new FirebaseOptions.Builder()
                .setProjectId("project-name")
                .setApplicationId("mobilesdk_app_id")
                .setApiKey("ApiKey")
                .build();
 FirebaseApp.initializeApp(this, options);

The above is been called in the application level of the project but i get the error Default FirebaseApp failed to initialize because no default options were found i get this error even if i add FirebaseApp.initializeApp(this, options, "secondary");以上是在项目的应用程序级别调用的,但我收到错误 Default FirebaseApp 初始化失败,因为没有找到默认选项,即使我添加FirebaseApp.initializeApp(this, options, "secondary");我也会收到此错误FirebaseApp.initializeApp(this, options, "secondary");

can anyone help out with this issue.任何人都可以帮助解决这个问题。 Can multiple projects be used like this of do i have a different understanding of Firebase multiple projects can they even be used analytics tracking.可以像这样使用多个项目吗?我对 Firebase 多个项目有不同的理解吗?它们甚至可以用于分析跟踪。

I'm not sure what you're trying to accomplish, but the Firebase Analytics SDK can only log events to a single app at a time, which is the default app.我不确定您要完成什么,但 Firebase Analytics SDK 一次只能将事件记录到一个应用程序,这是默认应用程序。 Calling initializeApp for other apps in the project won't change the way this works.为项目中的其他应用程序调用 initializeApp 不会改变其工作方式。

The only way that multiple apps are supported are for Firebase products that are not tied to the collection of Analytics.支持多个应用程序的唯一方法是针对与 Analytics 集合无关的 Firebase 产品。 And even then, it only makes sense for apps defined in multiple projects, not the same project.即便如此,它也只对定义在多个项目中的应用程序有意义,而不是同一个项目。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM