简体   繁体   中英

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. My question is is there a way to programmatically initailise these apps at runtime i have tried the following from the 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");

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.

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. Calling initializeApp for other apps in the project won't change the way this works.

The only way that multiple apps are supported are for Firebase products that are not tied to the collection of Analytics. And even then, it only makes sense for apps defined in multiple projects, not the same project.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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