Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Include Firebase Analytics in library

I have multiple Android apps that all include a custom library. This library is the core of the apps, and each app just contains a main activity extending an activity from the library to decide which flavour the specific app has.

I now want to include Firebase Analytics in the whole app, including the library, but I cannot wrap my head around how to. The google-services.json file should be different for each app, but I can not include the google-services plugin without a google-services file containing the library's package name.

I hope you have som ideas.

Thank you!

like image 940
Anddev Avatar asked Aug 05 '16 13:08

Anddev


People also ask

What is Google Firebase Analytics?

The base of Firebase is Google Analytics, which is an unlimited and free analytics solution. Across all the Firebase features, analytics will integrate to provide its users with unlimited reports for 500 events defined by users on Firebase SDK.

How do I collect data from Firebase?

Just add the Firebase SDK to your new or existing app, and data collection begins automatically. You can view analytics data in the Firebase console within hours. Log custom data. You can use Analytics to log custom events that make sense for your app, like E-Commerce purchases or achievements.

How do I use Firebase Analytics without IDFA collection?

If you wish to use Firebase Analytics without IDFA collection capability, open your / {ios|macos}/Podfile and add the following global variable to the top of the file: Once installed, you're ready to start using Analytics in your Flutter Project.

Where can I file issues for support using Firebase libraries?

For support using these libraries, file issues directly on GitHub. Libraries to simplify common Firebase tasks and integrations Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License.


1 Answers

You should add the google-services.json file and apply the google-services plugin to your app module, not the library project.

Most of the resources generated by the plugin are used dynamically and won't be necessary for the library to compile. However, if the library does use one of those resources explicitly (and therefore can't compile without it), the library can include a placeholder resource in its own strings.xml file which will eventually be overridden by the properly configured app.

like image 188
Steve Ganem Avatar answered Nov 15 '22 21:11

Steve Ganem